How can I optimize GraphViz output width?

In case the graph consists of several trees which are not connected, you could split them up (as mentioned in Graphviz: break flat but sparsely connected graph into multiple rows?)

Depending on your particular graph, you may obtain a smaller graph when using

ratio="compress"

(You'll have to specify size though)

For detailed optimizations on a specific graph, you may add rank attributes and distribute the nodes manually on different ranks.


Edit:

There is a graphviz tool called unflatten which seems to exist exactly for this purpose :

unflatten is a preprocessor to dot that is used to improve the aspect ratio of graphs having many leaves or disconnected nodes. The usual layout for such a graph is generally very wide or tall. unflatten inserts invisible edges or adjusts the minlen on edges to improve layout compaction.

Never had the need to use it, but I think it's worth a try.


I also had the problem that neato kept lots of space between the boxes. Finally I achieved a reasonable result using following graph settings in addition:

overlap=prism, overlap_scaling=0.01, ratio=0.7

It's especially useful testing different values for overlap_scaling and ratio. It's the quickest to use smaller examples (<50 nodes) and use gvedit.exe to see the effects.

It took me quite a while to identify these settings, which are documented at http://www.graphviz.org/doc/info/attrs.html


You can try to play with the ratio parameter.

Tags:

Ruby

Graphviz