gpt4 book ai didi

graphviz - 如何防止子图簇对齐顺序被颠倒?

转载 作者:行者123 更新时间:2023-12-01 11:18:57 25 4
gpt4 key购买 nike

如果我有这样的 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

如何防止这种情况发生并强制使用原始订购方法?

最佳答案

您必须在定义其他标签后定义您的长标签; 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

关于graphviz - 如何防止子图簇对齐顺序被颠倒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46554188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com