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

后端 未结 3 1109
攒了一身酷
攒了一身酷 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 15:52

    The ideal structure is actually rank max and rank min. No need for a subgraph or any other shenanigans. GraphViz has explicit facilities for this.

    With complex graphs, rank=same will often end up near the middle of the graph. If you mean top and bottom, say top and bottom.

    digraph G { 
    
      rankdir = TB;
    
      A -> B;
      A -> C -> D;
      X -> Y;
    
      { rank=min; A; X; }
      { rank=max; B; D; Y; }
    
    }
    

提交回复
热议问题