保留 grahpviz 子图中的节点顺序
Preserve order of nodes in grahpviz subgraph
如何让 graphviz 保留子图中节点的顺序?
请参阅下面的图片和代码。由于某种原因,第二个节点(编号为 2)显示在顶部,第一个节点显示在底部。
我看了这个问题,但没有解决问题(或者我不明白如何正确实施这些建议):
- Preventing graphviz from rearranging nodes
digraph G {
rankdir=LR
splines=line
nodesep=0.3;
ranksep=2
node [label=""];
// edge [dir=none];
edge[arrowhead="empty"];
// graph [ordering="out"];
subgraph cluster_0 {
color=white;
// {rank=same;x1;x2;x3;x4;x5}
node [style=solid,color=blue4, shape=circle];
x1 [label="1"] x2 [label="2"] x3 [label="3"] x4 [label="4"] x5 [label="5"];
}
subgraph cluster_1 {
color=white;
node [style=solid,color=red2, shape=circle];
edge[style=invisible]
a12 [label="1"] a22 [label="2"] a32 [label="3"] a42 [label="4"];
}
subgraph cluster_2 {
color=white;
node [style=solid,color=red2, shape=circle];
a13 a23 a33 a43;
}
subgraph cluster_3 {
color=white;
node [style=solid,color=seagreen2, shape=circle];
O1 O2 O3;
}
x1 -> a12;
x1 -> a22;
x1 -> a32;
x1 -> a42;
x2 -> a12;
x2 -> a22;
x2 -> a32;
x2 -> a42;
x3 -> a12;
x3 -> a22;
x3 -> a32;
x3 -> a42;
x4 -> a12;
x4 -> a22;
x4 -> a32;
x4 -> a42;
x5 -> a12;
x5 -> a22;
x5 -> a32;
x5 -> a42;
a12 -> a13
a22 -> a13
a32 -> a13
a42 -> a13
a12 -> a23
a22 -> a23
a32 -> a23
a42 -> a23
a12 -> a33
a22 -> a33
a32 -> a33
a42 -> a33
a12 -> a43
a22 -> a43
a32 -> a43
a42 -> a43
a13 -> O1
a23 -> O1
a33 -> O1
a43 -> O1
a13 -> O2
a23 -> O2
a33 -> O2
a43 -> O2
a13 -> O3
a23 -> O3
a33 -> O3
a43 -> O3
}
我也找不到成功使用 ordering 的方法。因为它们似乎没有被使用,所以我删除了 cluster 引用。此版本使用 weight 属性来保持节点的顺序。
digraph G {
rankdir=LR
splines=line
nodesep=0.3;
ranksep=2
node [label=""];
edge[arrowhead="empty"];
{
rank=same
node [style=solid,color=blue4, shape=circle];
x1 [label="1"] x2 [label="2"] x3 [label="3"] x4 [label="4"] x5 [label="5"];
edge [weight=50] // arbitrarily large integer
edge [style=invis]
x1->x2 x2->x3 x3->x4 x4->x5
}
{
rank=same
node [style=solid,color=red2, shape=circle];
edge[style=invisible]
a12 [label="1"] a22 [label="2"] a32 [label="3"] a42 [label="4"];
edge [weight=50] // arbitrarily large integer
edge [style=invis]
a12->a22 a22->a32 a32->a42
}
{
rank=same
node [style=solid,color=red2, shape=circle];
a13 a23 a33 a43;
}
{
rank=same
node [style=solid,color=seagreen2, shape=circle];
O1 O2 O3;
}
x1 -> a12;
x1 -> a22;
x1 -> a32;
x1 -> a42;
x2 -> a12;
x2 -> a22;
x2 -> a32;
x2 -> a42;
x3 -> a12;
x3 -> a22;
x3 -> a32;
x3 -> a42;
x4 -> a12;
x4 -> a22;
x4 -> a32;
x4 -> a42;
x5 -> a12;
x5 -> a22;
x5 -> a32;
x5 -> a42;
a12 -> a13
a22 -> a13
a32 -> a13
a42 -> a13
a12 -> a23
a22 -> a23
a32 -> a23
a42 -> a23
a12 -> a33
a22 -> a33
a32 -> a33
a42 -> a33
a12 -> a43
a22 -> a43
a32 -> a43
a42 -> a43
a13 -> O1
a23 -> O1
a33 -> O1
a43 -> O1
a13 -> O2
a23 -> O2
a33 -> O2
a43 -> O2
a13 -> O3
a23 -> O3
a33 -> O3
a43 -> O3
}
给予:
(是的,中间有很多失败)
如何让 graphviz 保留子图中节点的顺序?
请参阅下面的图片和代码。由于某种原因,第二个节点(编号为 2)显示在顶部,第一个节点显示在底部。
我看了这个问题,但没有解决问题(或者我不明白如何正确实施这些建议):
- Preventing graphviz from rearranging nodes
digraph G {
rankdir=LR
splines=line
nodesep=0.3;
ranksep=2
node [label=""];
// edge [dir=none];
edge[arrowhead="empty"];
// graph [ordering="out"];
subgraph cluster_0 {
color=white;
// {rank=same;x1;x2;x3;x4;x5}
node [style=solid,color=blue4, shape=circle];
x1 [label="1"] x2 [label="2"] x3 [label="3"] x4 [label="4"] x5 [label="5"];
}
subgraph cluster_1 {
color=white;
node [style=solid,color=red2, shape=circle];
edge[style=invisible]
a12 [label="1"] a22 [label="2"] a32 [label="3"] a42 [label="4"];
}
subgraph cluster_2 {
color=white;
node [style=solid,color=red2, shape=circle];
a13 a23 a33 a43;
}
subgraph cluster_3 {
color=white;
node [style=solid,color=seagreen2, shape=circle];
O1 O2 O3;
}
x1 -> a12;
x1 -> a22;
x1 -> a32;
x1 -> a42;
x2 -> a12;
x2 -> a22;
x2 -> a32;
x2 -> a42;
x3 -> a12;
x3 -> a22;
x3 -> a32;
x3 -> a42;
x4 -> a12;
x4 -> a22;
x4 -> a32;
x4 -> a42;
x5 -> a12;
x5 -> a22;
x5 -> a32;
x5 -> a42;
a12 -> a13
a22 -> a13
a32 -> a13
a42 -> a13
a12 -> a23
a22 -> a23
a32 -> a23
a42 -> a23
a12 -> a33
a22 -> a33
a32 -> a33
a42 -> a33
a12 -> a43
a22 -> a43
a32 -> a43
a42 -> a43
a13 -> O1
a23 -> O1
a33 -> O1
a43 -> O1
a13 -> O2
a23 -> O2
a33 -> O2
a43 -> O2
a13 -> O3
a23 -> O3
a33 -> O3
a43 -> O3
}
我也找不到成功使用 ordering 的方法。因为它们似乎没有被使用,所以我删除了 cluster 引用。此版本使用 weight 属性来保持节点的顺序。
digraph G {
rankdir=LR
splines=line
nodesep=0.3;
ranksep=2
node [label=""];
edge[arrowhead="empty"];
{
rank=same
node [style=solid,color=blue4, shape=circle];
x1 [label="1"] x2 [label="2"] x3 [label="3"] x4 [label="4"] x5 [label="5"];
edge [weight=50] // arbitrarily large integer
edge [style=invis]
x1->x2 x2->x3 x3->x4 x4->x5
}
{
rank=same
node [style=solid,color=red2, shape=circle];
edge[style=invisible]
a12 [label="1"] a22 [label="2"] a32 [label="3"] a42 [label="4"];
edge [weight=50] // arbitrarily large integer
edge [style=invis]
a12->a22 a22->a32 a32->a42
}
{
rank=same
node [style=solid,color=red2, shape=circle];
a13 a23 a33 a43;
}
{
rank=same
node [style=solid,color=seagreen2, shape=circle];
O1 O2 O3;
}
x1 -> a12;
x1 -> a22;
x1 -> a32;
x1 -> a42;
x2 -> a12;
x2 -> a22;
x2 -> a32;
x2 -> a42;
x3 -> a12;
x3 -> a22;
x3 -> a32;
x3 -> a42;
x4 -> a12;
x4 -> a22;
x4 -> a32;
x4 -> a42;
x5 -> a12;
x5 -> a22;
x5 -> a32;
x5 -> a42;
a12 -> a13
a22 -> a13
a32 -> a13
a42 -> a13
a12 -> a23
a22 -> a23
a32 -> a23
a42 -> a23
a12 -> a33
a22 -> a33
a32 -> a33
a42 -> a33
a12 -> a43
a22 -> a43
a32 -> a43
a42 -> a43
a13 -> O1
a23 -> O1
a33 -> O1
a43 -> O1
a13 -> O2
a23 -> O2
a33 -> O2
a43 -> O2
a13 -> O3
a23 -> O3
a33 -> O3
a43 -> O3
}
给予:
(是的,中间有很多失败)