我有一个这样的图形文件:
digraph {
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
}
}
Run Code Online (Sandbox Code Playgroud)
我希望子图step2detail挂在'Step2'的右边.
现在它看起来像这样:

我希望Step1,Step2和Step3全部垂直位于彼此之下且位于1列中.
小智 11
获取您描述的图形的技巧是使用两个子图并从一个子图链接到另一个子图."细节"中的隐形边缘使得音符保持对齐.
digraph {
rankdir="LR";
subgraph steps {
rank="same";
"Step1" -> "Step2" -> "Step3";
}
subgraph details {
rank="same";
edge[style="invisible",dir="none"];
"note1" -> "note2" -> "note3" -> "note4";
}
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
}
Run Code Online (Sandbox Code Playgroud)
通过将Step节点分组到聚簇子图中,输出如下:
digraph {
subgraph cluster_0 {
color=invis;
"Step1" -> "Step2" -> "Step3";
}
subgraph cluster_1 {
color=invis;
"Step2" -> "note4";
"Step2" -> "note3";
"Step2" -> "note2";
"Step2" -> "note1";
}
}
Run Code Online (Sandbox Code Playgroud)
http://i45.tinypic.com/2pyu7pk.jpg
color=invis 删除否则将在群集周围绘制的边框
这里很简单 - 只需使用该group属性让graphviz更喜欢直边:
digraph {
node[group=a, fontname="Arial", fontsize=14];
"Step1" -> "Step2" -> "Step3";
node[group=""];
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
}
Run Code Online (Sandbox Code Playgroud)
