2

我知道有一些相关的问题,但我想知道是否有更好的解决方案来强制 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];
}

节点顺序错误

4

1 回答 1

7

使用一些不可见边对子图中的节点进行排序,避免 LR 等级方向及其怪癖,使用不影响可见蓝色节点连接的节点 ( )排名的直边( ),应用默认样式以最小化重复和重新排序图形标记让我得到以下信息:splines=falseconstraint=false

digraph G {
    nodesep=4.0;
    splines=false;

    node[width=1, shape=circle, style=filled, fillcolor="#E3A869"];
    edge[style=invis];

    subgraph cluster_1 {
        label="Nr:1";
        "1-1" -> "1-2" -> "1-3" -> "1-4" -> "1-5";
    }

    subgraph cluster_2 {
        label="Nr:2";
        "2-1" -> "2-2" -> "2-3" -> "2-4" -> "2-5";
    }

    edge[style=solid, color=blue, penwidth=1, constraint=false];

    "1-1" -> "2-1";
    "1-2" -> "2-1";
    "1-3" -> "2-1";
    "1-4" -> "2-1";
    "1-5" -> "2-1";

    "1-1" -> "2-2";
    "1-2" -> "2-2";
    "1-3" -> "2-2";
    "1-4" -> "2-2";
    "1-5" -> "2-2";

    "1-1" -> "2-3";
    "1-2" -> "2-3";
    "1-3" -> "2-3";
    "1-4" -> "2-3";
    "1-5" -> "2-3";

    "1-1" -> "2-4";
    "1-2" -> "2-4";
    "1-3" -> "2-4";
    "1-4" -> "2-4";
    "1-5" -> "2-4";

    "1-1" -> "2-5";
    "1-2" -> "2-5";
    "1-3" -> "2-5";
    "1-4" -> "2-5";
    "1-5" -> "2-5";
}

graphivz 输出,子图节点使用不可见边排序

于 2013-04-02T19:03:46.303 回答