Graph autolayout algorithm

Associate
Joined
10 Jul 2006
Posts
2,423
I am currently working on a graph editor (assume just vertices and edges for now) and want to include a feature whereby the user clicks on a button and it automatically lays out the graph to make it look "pretty".

First problem is the definition of pretty, but looking past this I don't really know where to start.

I was thinking that each node could repel every other node by some contant and each node having a resistance constant to any repelling node. Then running this until each node converges.

This would just space the nodes out...if it would even work at all?...would it?

Any thoughts/ideas are apprechiated
 
Its a common problem, there is no 'perfect' way of drawing graphs. Surprisingly it can get pretty in depth...people have done phds on the subject because it has applications for automatically laying out electronic circuits etc, but for basic ones its pretty easy to do. graphviz is a library that will do it for you

This wiki link will give you some leads.
http://en.wikipedia.org/wiki/Graph_drawing
 
Last edited:
Have a look at yED it has lots of different ways to lay out graphs (there's a re-arrange graph option or something similar in the menus to do it). It's also a very nice editor. :)
 
Back
Top Bottom