graphviz 中的“{rank=same; A B C}”是什么语言结构

What language construct is " {rank=same; A B C} " in graphviz

在graphviz/dot中,我可以将节点放置在与{rank=same; ND1 ND2 ND3}相同的等级。

查看 dot language,我得出结论 {...} 子图语句 的一部分。

如果是这样的话,我不明白为什么我需要一个子图来对节点进行排序。我认为这是因为我对 graphviz 中子图的构成没有正确的心理印象。

所以,我的问题是:graphviz 中的子图到底是什么,为什么我必须启动一个子图来对与该子图没有任何关系的节点进行排名。

根据您引用的文档:

In the second role, a subgraph can provide a context for setting attributes. For example, a subgraph could specify that blue is the default color for all nodes defined in it. In the context of graph drawing, a more interesting example is:

subgraph { 
rank = same; A; B; C; 
} 

This (anonymous) subgraph specifies that the nodes A, B and C should all be placed on the same rank if drawn using dot.

这种使用子图来设置节点等级的方式正是文档所指的那种上下文(在这种情况下是明确的)。在这种情况下,语法 支持特殊的上下文 含义。