Search code examples
algorithmtreegraphdrawingvisualization

What's the best way to position interconnected nodes in a 2d graph?


I have a list (graph?) of nodes, and each node is connected to other nodes in the list one or more times. I want to take these nodes and lay them out in a nice 2d diagram with lines connecting them together in an optimal way. What's the best algorithm for doing this so that they're spaced evenly apart and the lines connecting them are as untangled as possible?


Solution

  • Someone implemented a force-directed graph in JavaScript and gave me permission to do what I want with it: http://www.reddit.com/r/programming/comments/bqr7v/force_directed_graph_layout_in_javascript/c0o4ka5?context=3