I have been trying to solve this problem in the past few days, But I don't know if this algorithm already exist.
So basically, in the image. I should be able to get 3 sets (enclosed ones)
A, C, D, B
C, D, F, E, G
A, C, F, G, E, D, B
I tried Breadth first but it seems that the "already visited" rule will not handle it, does anyone has an idea on which tree search I should look into?
The reason for this is for polygon separation.