it looks balanced when the tree itself is actually balanced:
but it’s being skewed If I add an 6
in this way:
can I force graphviz to lay out in a balanced way?
it looks balanced when the tree itself is actually balanced:
but it’s being skewed If I add an 6
in this way:
can I force graphviz to lay out in a balanced way?
Would you explain more about what balanced means in this case. Maybe just a pencil sketch.
Maybe a seemingly obvious brute force algorithm would suffice here? I’m not sure what’s considered state of the art now, but we need to handle arbitrary fanout, and variable width nodes.
Simplest (?) way is to define invisible nodes that are used to “fill out” the tree to make it symmetric
digraph T{
node [shape=circle width=.6]
10 -> { 85 30 7}
85 -> { 31 15 40}
30 -> {63 1 "15a" [label="15"]}
7 // define visible node
node [label="" style=invis]
edge [style=invis]
7 -> {dummy1 dummy2 dummy3 }
}
Giving: