我有一个这样的图形文件:
digraph {
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
}
}
我希望子图step2detail悬挂在'Step2'的右边。
现在它看起来像这样:
我希望Step1,Step2和Step3全部垂直在彼此之下并且在1列中。
答案 0 :(得分:9)
获取您描述的图形的技巧是使用两个子图并从一个子图链接到另一个子图。 “细节”中的隐形边缘使得音符保持一致。
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";
}
结果是:
答案 1 :(得分:7)
通过将Step节点分组到聚簇子图中,输出如下:
digraph {
subgraph cluster_0 {
color=invis;
"Step1" -> "Step2" -> "Step3";
}
subgraph cluster_1 {
color=invis;
"Step2" -> "note4";
"Step2" -> "note3";
"Step2" -> "note2";
"Step2" -> "note1";
}
}
color=invis
删除原本会在群集周围绘制的边框
答案 2 :(得分:7)
这里很简单 - 只需使用group
属性让graphviz更喜欢直接
边缘:
digraph {
node[group=a, fontname="Arial", fontsize=14];
"Step1" -> "Step2" -> "Step3";
node[group=""];
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
}
答案 3 :(得分:0)
rankdir不能直接在子图中使用,但是如果您添加另一组花括号-不管怎么说,rankdir都可以工作:
digraph {
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
{
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
rank=same
}
}
}
答案 4 :(得分:-3)
使用命令:rankdir = LR;
digraph {
rankdir=LR;
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
}
}