FaqBalanceTree

 

How can I symmetrize (balance) tree layouts?

When a tree node has an even number of children, it isn't necessarily centered above the two middle ones. If you know the order of the children, a simple hack is to introduce new, invisible middle nodes to re-balance the layout. The connecting edges should also be invisible. For example:

  • digraph G {
    • a -> b0
      xb [label="",width=.1,style=invis]
      a -> xb [style=invis]
      a -> b1
      {rank=same b0 -> xb -> b1 [style=invis]}
      b0 -> c0
      xc [label="",width=.1,style=invis]
      b0 -> xc [style=invis]
      b0 -> c1
      {rank=same c0 -> xc -> c1 [style=invis]}

    }

This trick really ought to be build into our solver (and made independent of the order of the children, and available for layouts other than trees, too).

GraphvizWiki: FaqBalanceTree (last edited 2008-01-16 20:26:37 by H-135-207-131-158)

Recent comments