I'm trying to create a graphic network with dot. and Graphiz.
So far this is my code:
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]
}
This is what I get:
This is what I would like to obtain:
How to put the subgraphs in the correct order?
Thank you everyone in advance for your help! Kind regards!
Defining the edges in the order as desired helps. Your version puts 1 2 10 11
in the same rank, hence they are set one below the other.
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 };
}
yields
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With