dot - 在 dot graphviz 中从左到右订购框

标签 dot

我有这个 gv 代码,

我想要水平顺序:
12 13 14 15 23 24

但我得到:

23 13 12 24 14 15

graph "tree" {
node [shape=plaintext];

1  [label = "1"]
2  [label = "2"]
3  [label = "3"]
4  [label = "4"]
5  [label = "5"]
12 [label = "12"]
13 [label = "13"]
14 [label = "14"]
15 [label = "15"]
23 [label = "23"]
24 [label = "24"]

1 -- 12;
2 -- 12;
1 -- 13;
3 -- 13;
1 -- 14;
4 -- 14;
1 -- 15;
5 -- 15;
2 -- 23;
3 -- 23;
2 -- 24;
4 -- 24;}  

解决方法:Force the left to right order of nodes in graphviz?在这种情况下不起作用(排序节点而不是边缘)。

enter image description here

如果我添加:
{rank = same; 12 13 14 15 23 24; rankdir=LR;}

我们得到相同的无序节点:

png 文件由:
dot -T png test.gv > test.png

最佳答案

或者更简单:

graph "tree" {
    node[shape=plaintext]

    1 -- {12 13 14 15}
    2 -- {12 23 24}
    3 -- {13 23}
    4 -- {14 24}
    5 -- 15;

    {
        rank = same; 
        12 -- 13 -- 14 -- 15 -- 23 -- 24 [color=invis]
    }
}

enter image description here

关于dot - 在 dot graphviz 中从左到右订购框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34228322/

相关文章:

Bash 和 (graphviz) 点输出重定向

GraphViz 点文件。节点作为国际象棋顺序

python - 在一个点文件中解析多个有向图

graphviz点: have two clusters with nodes in between

c - 二叉树插入动画GIF

graphviz - 点状工具提示(graphviz)

uml - DOT 格式的 UML 状态图中的子状态

html - 如何使用 Graphviz HTML 表格去除边框间距?

graph-theory - 用图点连接边