How do I place nodes on the same level in DOT?

后端 未结 3 1082
攒了一身酷
攒了一身酷 2021-01-31 15:09

I want to render several trees simultaneously and place all root nodes and all leaf nodes on the same level.

Here\'s an example of what I\'m trying to do. Root nodes A a

3条回答
  •  北海茫月
    2021-01-31 15:46

    Putting the rank = same; ... statements in braces, e.g.:

    digraph G { 
      rankdir = TB;
      subgraph {
        A -> B
        A -> C
        C -> D
        X -> Y
        // note that rank is used in the subgraph
        {rank = same; A; X;}
        {rank = same; B; D; Y;}
      } /* closing subgraph */
    }
    

    ... gives the desired result:

    enter image description here

提交回复
热议问题