Graphviz DOT arrange Nodes in circles, layout too "compact"

Ivo Wetzel picture Ivo Wetzel · Apr 16, 2010 · Viewed 19.5k times · Source

I'm halfway there please see the edit

OK here's my problem, I'm generating a graph of a python module, including all the files with their functions/methods/classes.

I want to arrange it so, that nodes gather in circles around their parent nodes, currently everything is on one gargantuan horizontal row, which makes the thing >50k pixels wide and also let's the svg converter fail(only renders about the half of the graph).

I went through the docs but couldn't find anything that seems to do the trick.

So the question is:
Is there a simple way to do this or do I have to layout the whole thing by myself? :/

EDIT:
Thanks to Andrews comment I've got the right layout, the only problem now is that it's a bit to "compact"... so the question now is, how to fix this?

Test

Answer

doug picture doug · Apr 16, 2010

i've mentioned all of the most significant parameters that influence your current layout and then suggested values for those parameters. Still, i suspect you can get the layout that you want just from applying a couple of these suggestions.

  • reduce the edge weight, eg, [weight=0.5]; this will make the edges longer, causing the tight clusters you currently see in your graph to 'fan out'.

  • get rid of the node borders, node_A [color=none; shape=plaintext]; especially for oval-shaped nodes, a substantial fraction of the total node space is 'unused' (ie, not used to display the node label).

  • explicitly set the font size for the nodes (the node borders are enlarged so that they surround the node text, which means that the font size and amount of text for a given node has a significant effect on its size); [fontsize=11] should be large enough to be legible yet also reduce the 'cluttered' appearance (the default size is 14).

  • increase minimum separation between nodes, via 'nodesep'; eg, nodesep=2.0; this will directly address your objection regarding your graph being "too compact." ('nodesep' and 'ranksep' probably affect how dot draws a graph more than any other parameters for node, edge, or graph. In your case, it looks like you have only two ranks of nodes; 'ranksep' sets the minimum distance between nodes of different ranks--it looks like all of the nodes that comprise your graph are of the same rank (except for few top level nodes in the centers).

  • explicitly set total graph size, eg, size="7.75,10.25" (ensures that your graph fits on an 8.5 x 11 page and that it occupies the entire space)

  • And one purely aesthetic suggestion that at most will only help your graph appear less cluttered: the default fontcolor for both edges and nodes is black. The majority of the ink on your graph is from those two structures (particularly if you remove the node borders), so i would for instance set either the node (text) fontcolor or the edge fontcolor to "blue" to help the eye distinguish the two sets of graph structures.