GraphViz-当主图从上到下时,如何使子图从左到右?
我有这样一个图形文件:GraphViz-当主图从上到下时,如何使子图从左到右?,graphviz,Graphviz,我有这样一个图形文件: digraph { "Step1" -> "Step2" -> "Step3"; subgraph step2detail { "Step2" -> "note1"; "Step2" -> "note2"; "Step2" -> "note3"; "Step2" -> "note4"; rankdir=TB } } 我希望子图ste
digraph {
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
}
}
我希望子图step2detail挂在“Step2”的右侧
现在看起来是这样的:
digraph {
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
}
}
我希望Step1、Step2和Step3都在一列中彼此垂直放置。通过将Step节点分组到一个聚集子图中,输出如下:
digraph {
subgraph cluster_0 {
color=invis;
"Step1" -> "Step2" -> "Step3";
}
subgraph cluster_1 {
color=invis;
"Step2" -> "note4";
"Step2" -> "note3";
"Step2" -> "note2";
"Step2" -> "note1";
}
}
color=invi
删除否则将围绕群集绘制的边框使用命令:rankdir=LR
digraph {
rankdir=LR;
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
}
}
获取您描述的图的技巧是使用两个子图并从一个子图链接到另一个子图。“细节”中不可见的边缘是保持音符对齐的原因
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";
}
结果是:
这是最简单的方法-只需使用
组属性让graphviz更喜欢直线
边缘:
rankdir不能直接在子图中工作,但是如果您添加另一组花括号-不管它叫什么-rankdir工作:
digraph {
"Step1" -> "Step2" -> "Step3";
subgraph step2detail {
{
"Step2" -> "note1";
"Step2" -> "note2";
"Step2" -> "note3";
"Step2" -> "note4";
rankdir=TB
rank=same
}
}
}
不错,但看起来很奇怪;第1步->第2步->第3步不在同一个垂直位置更改子图的rankdir似乎不会改变任何东西=\n我不知道原始提问者的想法,但根据问题的描述,这给出了我想象中想要的东西——我想这将帮助我获得我自己的图形所需要的东西。:)也许晚了,但我用这个问题和本页底部的示例解决了我正在处理的图表中的类似问题。因此,我认为您的解决方案可以在没有子图和rankdir的情况下完成。很抱歉格式化。有向图{Step1->Step2->Step3 Step2->note4,note3,note2,note1{rank=same Step2,note1,note2,note3,note4}