Problem 60987. Build triangulation from -sorted- edge list
Problem statement
An edge list is simply a N x 2 matrix of positive integers, in which N is the number of edges and each integer is a vertex index. Like this, an edge is defined by the indices of its two vertices.
A triangulation is simply a M x 3 matrix of positive integers, in which M is the number of triangles and each integer is a vertex index. Like this, a triangle is defined by the indices of its three vertices.
In this problem the gaol is to rebuild the triangulation from the ordered edge list.
Example (check the test suite here below for more)
E = [1 2;
1 3;
2 3];
=>
T = [1 2 3];
Tips & clues
- Since a triangle always has 3 edges, you could process the edge list by blocks of 3 rows;
- Triangles orientation (vertices order in the list) doesn't matter here : [1 2 3] and [1 3 2] are a same unique triangle;
- On the other hand, the order of the triangles in the list should be preserved;
- You could see this as the reciprocal operation to the one of building the edge list (E = nchoosek(T,2) )
Forbidden functions / expressions
- regexp
- assignin
- str2num
- echo
See also
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
More from this Author42
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!