The edges define an undirected graph G
and the triangles are the set of cycles in G
with length=3
.
Geometric triangulations typically have relatively low nodal degree (degree d
is the number of edges adjacent to each node, d<=10
is typical for geometric triangulations) and, as such, here is a reasonably efficient O(n*d^3)
algorithm that can be used to construct the set of triangles.
Setup a graph-like data structure, supporting access to the list of edges adjacent to each node.
Iterate over all nodes. Consider all pairs of edges adjacent to a given node
i
. For a given pair of edges adjacent toi
, we have a potential nodal tripleti,j,k
. This triplet is a triangle if there is an edge joining nodesj,k
, which can be checked by scanning the edge lists ofj,k
.
Duplicate triangles will be generated by a naive implementation of (2)
. Maintain a hash table of triangles to reject duplicate triplets as they're considered.
I've assumed that the edges define a valid disjoint triangulation, being non-intersecting, etc.
Hope this helps.