2017-10-14 66 views
1

我试图创建一个带点的图形网络。和Graphiz。Graphviz子图顺序

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

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

如何把子图按正确的顺序?

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

回答

3

根据需要定义边缘的顺序有帮助。您的版本将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

+0

你好@vaettchen,它工作得很好!非常感谢您的时间和帮助! – 3lli0t

+0

在cluster_3中,我会使用color =“invis” – Misi