Graphviz 子图不能被视觉化

我试图创建一个带有两个子图的点图。代码如下:

digraph G {
subgraph step1 {
style=filled;
node [label="Compiler"] step1_Compiler;
node [label="Maschine"] step1_Maschine;
color=lightgrey;
}


subgraph step2 {
style=filled;
color=lightgrey;
node [label="Interpretierer"] step2_Interpretierer;
node [label="Maschine"] step2_Maschine;
label="Virtuelle Maschine";
}


"Programm (Java)" -> step1_Compiler;
step1_Compiler -> step1_Maschine;
step1_Maschine -> "Bytecode";
"Bytecode" -> step2_Interpretierer;
step2_Interpretierer -> step2_Maschine;
step2_Maschine -> "Ergebnis";
}

我得到的结果如下:

Result of above code

我希望在两个子图周围都能看到一个框。我错过了什么?

20915 次浏览

You'll have to prefix the name of your subgraphs with 集群:

subgraph clusterstep1 {

and

subgraph clusterstep2 {

in order to get the style and label.

From the Graphhiz 文档,“子图和集群”部分:

子图的第三个角色直接涉及到图的形式 如果子图的名字开始 对于集群,Graphviz 将子图记录为一个特殊的集群 子图 。如果支持,布局引擎将执行布局,以便 属于集群的节点被绘制在一起,其中包含整个 包含在一个边框中的集群的绘制。注意 that, for good and bad, cluster subgraphs are not part of the DOT 语言,但仅仅是某些语言所遵循的一种句法惯例 布局引擎。