在Graphviz中使用子图时对齐节点
我想在Graphviz中使用子图时对齐节点 它在没有子图的绘图中工作得非常好。但当我引入子图时,节点发生了(意外的?)移动 下面是一个简单的例子在Graphviz中使用子图时对齐节点,graphviz,subgraph,Graphviz,Subgraph,我想在Graphviz中使用子图时对齐节点 它在没有子图的绘图中工作得非常好。但当我引入子图时,节点发生了(意外的?)移动 下面是一个简单的例子 digraph My_test_without_subgraphs { graph [overlap = true, compound = true, rankdir = LR] node [shape = box, color = lightgrey, style = filled, fontcolor = black] T1 [la
digraph My_test_without_subgraphs {
graph [overlap = true, compound = true, rankdir = LR]
node [shape = box, color = lightgrey, style = filled, fontcolor = black]
T1 [label = 'my task 1']
T2 [label = 'my task 2']
T3 [label = 'my task 3']
T4 [label = 'my task 4']
T1 -> T3
T2 -> T3
T3 -> T4
}
digraph My_test_with_subgraphs {
graph [overlap = true, compound = true, rankdir = LR]
node [shape = box, color = lightgrey, style = filled, fontcolor = black]
T1 [label = 'my task 1']
T2 [label = 'my task 2']
T3 [label = 'my task 3']
T4 [label = 'my task 4']
subgraph cluster1 {
label = 'cluster 1'
color = cornsilk
style = filled
T1 -> T3
T2 -> T3
}
subgraph cluster2 {
label = 'cluster 2'
color = cornsilk
style = filled
T3 -> T4
}
}
向第二个簇添加一个略小的边距,如下所示:
margin = 7.99
这就是诀窍
别问我为什么…是的,保证金起作用。值本身并不重要,只要它是一个小于8的数字 顺便说一句,请使用“代替”,一些口译员,特别是在线编辑,会出现错误
digraph My_test_without_subgraphs {
graph [overlap = true, compound = true, rankdir = LR]
node [shape = box, color = lightgrey, style = filled, fontcolor = black]
T1 [label = "my task 1"]
T2 [label = "my task 2"]
T3 [label = "my task 3"]
T4 [label = "my task 4"]
T1 -> T3
T2 -> T3
T3 -> T4
}
结果:
及
导致
谢谢。在这个简单的例子中效果很好,但在更复杂的绘图(三个子图,更多节点)中,这个技巧不起作用……你知道我们如何“推广”这个技巧吗?对不起,这是一个幸运的机会,不知道如何正确地做到这一点。
digraph My_test_with_subgraphs {
graph [overlap = true, compound = true, rankdir = LR]
node [shape = box, color = lightgrey, style = filled, fontcolor = black]
T1 [label = "my task 1"]
T2 [label = "my task 2"]
T3 [label = "my task 3"]
T4 [label = "my task 4"]
subgraph cluster1 {
label = "cluster 1"
color = cornsilk
style = filled
T1 -> T3
T2 -> T3
}
subgraph cluster2 {
margin = 6
label = "cluster 2"
color = cornsilk
style = filled
T3 -> T4
}
}