简体   繁体   English

如何在DOT图中设置固定的深度级别

[英]How to set fixed depth levels in DOT graphs

I'm creating a DOT graph visualization from a tree-like data structure but am having difficulties setting fixed level depths based upon data type. 我正在从树状数据结构创建DOT图形可视化,但是根据数据类型设置固定级别深度很困难。 For example, if I had 4 nodes in a tree and A denotes a specific data type and B represents another it would like Graph_1: 例如,如果我在树中有4个节点,A表示特定数据类型而B表示另一个,则它想要Graph_1:

  ROOT / \\ A[0] B[1] / B[0] 

as opposed to Graph_2: 与Graph_2相反:

  ROOT / \\ A[0] \\ / \\ B[0] B[1] 

Graph_2 is what I would like to end up with. Graph_2是我想要的结果。

The fixed levels are what I'm looking for. 固定水平是我正在寻找的。 How can I achieve this? 我怎样才能做到这一点? I can easily identify what data type I'm adding to the graph, but am having trouble on how to tag nodes to achieve this. 我可以很容易地识别出我正在添加到图表中的数据类型,但是在如何标记节点以实现此目的方面遇到了麻烦。 Can this be done using subgraphs? 可以使用子图完成吗?

FYI, this is my first time playing with DOT. 仅供参考,这是我第一次玩DOT。

Yes, subgraphs will work. 是的,子图将起作用。

digraph {
  subgraph { rank = same; A0 };
  subgraph { rank = same; B0; B1 };
  root -> A0;
  A0 -> B0;
  root -> B1;
}

results in 结果是

替代文字
(source: brool.com ) (来源: brool.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM