1

I'm trying to render a tree that is very broad... and it renders, as expected, in a long, skinny horizontal image.

Problem is that I need a graph suitable for a document. I would very much like to take and move the nodes that are rendered horizontally and "drag" them down so that the graph is more vertical... with the edges curving to accommodate this. Are there any clever ways to accomplish this? GraphViz settings? Third party tools that let me manipulate and fine tune the output? I work mostly in the Python ecosystem, but open to others. Also open to the use of tools like Visio and other pro drawing tools. Thanks!

Edit

After implementing the answer below by @sroush, and then tweaking a little further with Photoshop, got some nice results.

Tweaking the above in Photosop. Had to add the two curved edges after the secondary node by hand, but it's worth it. Much more presentable.

Trekkie
  • 964
  • 1
  • 9
  • 32

2 Answers2

3

I assume you are using dot, and your graph "naturally" has only a few ranks (rows).
There are a few tweaks that will help a bit (reducing node horizontal footprints):

  • node [shape=rect] // snugger fit into rectangles
  • insert newlines into node labels e.g. xxx [label="Controller Board\n@19_8"])

Also try the unflatten program (https://www.graphviz.org/pdf/unflatten.1.pdf). It will increase the apparent number of ranks (rows).

See related question here with command line examples: Distribute nodes on the same rank of a wide graph to different lines

Trekkie
  • 964
  • 1
  • 9
  • 32
sroush
  • 5,375
  • 2
  • 5
  • 11
  • Thanks for making me aware of unflatten! And yep, I'm def going to try tweaking the .dot file directly now. Also, going to add a link to an existing SO question to supplement your answer in case it helps others. Thanks! – Trekkie Aug 06 '22 at 18:30
3

You can use the minlen property to limit the minimum level span of some edges.This avoids the result becoming very long in the horizontal position. For example:

digraph {
a->b
a->c
a->d
a->e
}

This will output the following image: enter image description here

But when minlen is used, the picture will become longer vertically but shortened horizontally:

digraph {
a->b
a->c
a->d[minlen=2]
a->e[minlen=3]
}

enter image description here