0

I'm trying to create a graph with as many straight edges as possible between points without allowing any of the edges to intersect in Java. Basically, I'm trying to make a planar graph with a random amount of points. I somewhat understand how to detect a planar graph when given a graph that already has edges but I'm confused about how to actually create a planar graph from just random nodes. The only way that comes to mind is to randomly create graphs and then test them but this seems very inefficient.

Thanks

John Smith
  • 617
  • 1
  • 10
  • 19
  • 3
    http://stackoverflow.com/questions/3232048/generate-a-large-random-planar-graph – NPE Mar 02 '13 at 21:16
  • If you want brute force solution which I think will be like O(n^2 log n) or even worse, just try to add edge between each two points (maybe breadth first, shortest edges first for max edge count), but test each new edge against all edges already added, and don't add if there is intersection. For better, see the link in 1st comment. – hyde Mar 02 '13 at 21:33

0 Answers0