Problem 45257. Find neighbor triangle indices

First input T is a triangulation (triplet list of indices -positive integers-, each index refering to a vertex number in a corresponding vertices list).

Given a second input t (a certain triangle row index), one would like to query the list L of all its triangle neighbor indices. A triangle is neighbor to another triangle if they share exactly one edge.

For instance if

T = [1 2 4;...
     2 3 4;...
     5 6 8;...
     6 7 8;...
     1 2 5;...
     2 5 6;...
     2 3 6;...
     3 6 7;...
     3 4 7;...
     4 7 8;...
     4 1 8;...
     1 8 5]

and t = 3, then the function should return

L = [4, 6, 12]'

since rows / (triangles of T) 4, 6, and 12 contain an edge in common with triangle / row 3.edge [6 8] for the first, edge [5 6] for the second, and edge [8 5] for the third.

Hypothesis :

- Since a triangle is not considered neighbor of itself, t should not be part of L.

- Order doesn't matter, but T must be a column vector containing all the neighbor triangle -row- indices (except itself then) once only. No duplicata is admitted.

- Edges are symmetric : [e1, e2] is the same edge as [e2, e1]

- Every indices are positive, distinct integers.

Solution Stats

65.38% Correct | 34.62% Incorrect
Last Solution submitted on Feb 06, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers14

Suggested Problems

More from this Author9

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!