QLands
QLands

Reputation: 2586

GraphViz Dot. How to distribute elements around a boxed size?

I have a dot graphviz file that geneates the following output:

http://www.qlands.com/other_files/test.png

However the output is organized vertically. If I setup the size to be for example 8.27 inches; How can I distribute the elements around a box of 8.27 x 8.27 inches?

Upvotes: 2

Views: 971

Answers (1)

marapet
marapet

Reputation: 56466

Your graph is a directed graph layed out with dot from left to right, and the first rank contains many nodes which results in a very high image.

The main tool to break up graphs with this problem is unflatten:

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.

You may combine this with other tools and techniques to get the result you want:

  • Use the unflatten utility - please see this answer for a detailed example using unflatten.
  • Use invisible edges to introduce new ranks (basically what unflatten does automatically, but with human inspiration... example also here)
  • If you need the output to be of this exact size, be sure to understand graphviz's various attributes which have an impact on it, such as size, margin, ratio... (see also this and yet another answer providing details)
  • Finally, you could simply use a different layout (neato for example)

Upvotes: 3

Related Questions