我知道有一些相关的问题,但我想知道是否有更好的解决方案强制graphviz以定义的顺序保持节点位置。
这是我的问题: 我有两个子图,每5个节点。每个节点都连接到另一个图的每个节点。我希望节点按顺序从1-1到1-5。但是graphviz总是将它们混合起来。
这是图表,我正在使用DOT:
digraph G {
rankdir=LR;
ranksep=4.0;
subgraph cluster_1 {
rank=same;
label="Nr:1";
"1-1" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="1-1"];
"1-2" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="1-2"];
"1-3" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="1-3"];
"1-4" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="1-4"];
"1-5" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="1-5"];
}
subgraph cluster_2 {
rank=same;
label="Nr:2";
"2-1" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="2-1"];
"1-1" -> "2-1" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-2" -> "2-1" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-3" -> "2-1" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-4" -> "2-1" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-5" -> "2-1" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"2-2" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="2-2"];
"1-1" -> "2-2" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-2" -> "2-2" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-3" -> "2-2" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-4" -> "2-2" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-5" -> "2-2" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"2-3" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="2-3"];
"1-1" -> "2-3" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-2" -> "2-3" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-3" -> "2-3" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-4" -> "2-3" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-5" -> "2-3" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"2-4" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="2-4"];
"1-1" -> "2-4" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-2" -> "2-4" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-3" -> "2-4" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-4" -> "2-4" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-5" -> "2-4" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"2-5" [width=1, shape=circle, style=filled, fillcolor="#E3A869", label="2-5"];
"1-1" -> "2-5" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-2" -> "2-5" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-3" -> "2-5" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-4" -> "2-5" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
"1-5" -> "2-5" [color=blue, labelfontcolor="#009933", fontsize="10.0", penwidth=1];
}
答案 0 :(得分:7)
使用不可见边来排序子图中的节点,避免LR排名方向及其怪癖,使用直边({ {1}})不影响可见蓝色节点连接的节点(splines=false
)的排名,应用默认样式以最小化重复并重新排序图标标记得到我以下内容:
constraint=false