Algorithm for laying out the nodes on a graph.

I’ve got a directed graph that I’m using in one of my projects. Think something like the civilization tech tree. But more tangled. There is a general generational flow from one side to the other, but there are a lot of links that cross several generations.

Drawing the nodes and edges is straight forward. But I’m having trouble laying the graph out in a clean, visually simple fashion. I can do it by hand, tweaking the position of each node individually. But this is a pain, especially because I’m still iterating on the shape of the graph. Ultimately the graph will become too complex for hand optimization to be possible.

So is anyone aware of any algorithms out there that I could use to auto layout this thing? I’ve attached an example below of one I’ve done by hand.

Something like graphviz or touchgraph - neither are c# but graphviz does have c# wrappers etc…

1 Like

For .NET there is Microsoft Automatic Graph Layout, but dunno if it will work with Unity.

2 Likes