如何防止子图集对齐顺序被反转?

时间:2017-10-03 22:10:31

标签: graphviz dot

如果我有这样的graphviz dot脚本:

digraph g {
node [style=rounded, shape=box]

    subgraph cluster1 {
        style="invis"
        1 -> 2 -> 3 -> 4 -> 5
    }

    subgraph cluster2 {
        style="invis"
         6 -> 7

         7 -> 8 -> 11
         7 -> 9 -> 11
         7 -> 10 -> 11
    }

    edge[constraint=false];
    splines="ortho"
    5 -> 6 [weight=0]
}

我得到的输出看起来像这样(我想要的):

enter image description here

但是,如果最后一些节点中的标签变得太长,则排列方式会反过来:

digraph g {
node [style=rounded, shape=box]

8 [label="very long label"]
9 [label="very long label"]
10 [label="very long label"]


    subgraph cluster1 {
        style="invis"
        1 -> 2 -> 3 -> 4 -> 5
    }

    subgraph cluster2 {
        style="invis"
         6 -> 7

         7 -> 8 -> 11
         7 -> 9 -> 11
         7 -> 10 -> 11
    }

    edge[constraint=false];
    splines="ortho"
    5 -> 6 [weight=0]
}

enter image description here

如何防止这种情况并强制执行原始排序方法?

1 个答案:

答案 0 :(得分:5)

在定义了另一个之后,您必须定义长标签; graphviz按照定义的顺序绘制节点。

digraph g {
node [style=rounded, shape=box]

    subgraph cluster1 {
        style="invis"
        1 -> 2 -> 3 -> 4 -> 5
    }

    subgraph cluster2 {
        style="invis"
         6 -> 7

         7 -> 8 -> 11
         7 -> 9 -> 11
         7 -> 10 -> 11
    }

    8 [label="very long label"]
    9 [label="very long label"]
    10 [label="very long label"]

    edge[constraint=false];
    splines="ortho"
    5 -> 6 [weight=0]
}

产量

enter image description here