Graphviz子图顺序

标签 graphviz dot

我正在尝试用点创建一个图形网络。和 Graphiz。

到目前为止,这是我的代码:

  graph {
rankdir  = LR;
splines=line;       

subgraph cluster_1{            
    1; 2;
}
subgraph cluster_2{
    b; c;
}

subgraph cluster_3{
color = white       
    10;11;
}

b -- {1 2 10 11}[color = blue];
c -- {1 2 10 11}[color = yellow];   



1[label = "1", style = filled, fillcolor = grey91]
2[label = "2", style = filled, fillcolor = grey91]
b[label = "B", style = filled, fillcolor = blue]
c[label = "C", style = filled, fillcolor = yellow]
10[label = "10", style = filled, fillcolor = grey91]
11[label = "11", style = filled, fillcolor = grey91]

}

这是我得到的:

enter image description here

这是我想要得到的: enter image description here

如何将子图按正确的顺序排列?

提前感谢大家的帮助! 亲切的问候!

最佳答案

根据需要按顺序定义边会有所帮助。您的版本将 1 2 10 11 置于同一等级,因此它们被设置为一个在另一个之下。

graph 
{
    rankdir = LR;
    splines = line;

    node[ style = filled, fillcolor = grey91 ];
    1 2 10 11;
    b[ label = "B", fillcolor = blue   ];
    c[ label = "C", fillcolor = yellow ];


    subgraph cluster_1
    {            
        1; 2;
    }
    subgraph cluster_2
    {
        b; c;
    }
    subgraph cluster_3
    {
        color = white       
        10; 11;
    }

    edge[ color = blue ]
    { 1 2 } -- b -- { 10 11 };
    edge[ color = yellow ]
    { 1 2 } -- c -- { 10 11 };
}

产量

enter image description here

关于Graphviz子图顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46743365/

相关文章:

java - 以点文件的形式生成AST

syntax-error - Snakemake --force all --dag 导致神秘错误 : <stdin>: syntax error in line 1 near 'File' from Graphvis

d3.js - 在javascript/d3中读取DOT文件

Flask 动态 graphviz 和 SVG 示例

graphviz - 如何在Graphviz中使边重叠?

dot - Graphviz Dot 将节点放置在子图中,即使它是在其他地方定义的

c - 如何在linux中添加graphviz库?

graphviz - 如何使用graphviz混合过滤器

php - Graphviz 关注一个节点