Segment crossing algorithm

129 Views Asked by At

I need an ideea of an algorithm to solve a puzzle 'game'. The game is :

  • is given N number of line segments by coordinates [(X1n,Y1n),(X2n,Y2n)]
  • some of segments have the same ends

We've got something like :

unsolved puzzle

To solve the puzzle we need to move ends of segments in such a way that none of segments intersect (cross), except for ends. The above example solved, looks like :

enter image description here

Does anybody have an idea on how to solve this type of puzzle ?

1

There are 1 best solutions below

0
On

If the graph is not planar, than there is no solution. If the graph IS planar, there are many solutions, but they are somewhat complicated. See this Wikipedia page.