Splitting Graph into distinct polygons in O(E) complexity

Posted by Arthur Wulf White on Game Development See other posts from Game Development or by Arthur Wulf White
Published on 2012-11-13T17:31:25Z Indexed on 2012/11/13 23:24 UTC
Read the original article Hit count: 335

Filed under:
|
|

If you have seen my last question: trapped inside a Graph : Find paths along edges that do not cross any edges

How do you split an entire graph into distinct shapes 'trapped' inside the graph(like the ones described in my last question) with good complexity?

Graph split into shapes

What I am doing now is iterating over all edges and then starting to traverse while always taking the rightmost turn. This does split the graph into distinct shapes. Then I eliminate all the excess shapes (that are repeats of previous shapes) and return the result.

The complexity of this algorithm is O(E^2). I am wondering if I could do it in O(E) by removing edges I already traversed previously. My current implementation of that returns unexpected results.

© Game Development or respective owner

Related posts about geometry

Related posts about polygon