Cluster extruded nodes in Graphviz

I want to draw several related subgraphs in GraphViz. When I draw simple nodes, it looks very beautiful:

enter image description here

Resources:

digraph {
rankdir=LR;

A1 -> A21;
A1 -> A22;
A1 -> A23;
A1 -> A24;

B1 -> B21;
B1 -> B22;
B1 -> B23;
B1 -> B24;

A21 -> A31;
A22 -> A31;
A23 -> A31;

A23 -> A32;

B21 -> B31 ;

B21 -> B32;
B22 -> B32;

B21 -> B33;
B23 -> B33;
}

Since the nodes of the same level in several subgraphs are related, I want to group them and give it a label.
I tried to do it with clustering, but it “squeezed” the nodes:< /p>

enter image description here

Resources:

digraph {
rankdir=LR;

subgraph cluster_level1 {
label = "Level 1";
style= filled;
color=lightgrey;

A1;
B1;
}

subgraph cluster_level2 {
label = "Level 2";
style=filled;
color=lightgrey;

A21;
A22;
A23;
A24;

B21;
B22;
B23;
B24;
}

subgraph cluster_level3 {
label = "Level 3";
style=filled;
color=lightgrey;

A31;
A32;

B31;
B32;
B33;
}

A1 -> A21;
A1 -> A22;
A1 -> A23;
A1 -> A24;

B1 -> B21 ;
B1 -> B22;
B1 -> B23;
B1 -> B24;

A21 -> A31;
A22 -> A31;
A23 -> A31;

A23 -> A32;

B21 -> B31;

B21 -> B32;
B22 -> B32;

B21 -> B33;
B23 -> B33;
}

There are only two subgraphs, which is terrible, But still not very bad. But if I add more subgraphs, it will become more ugly and ugly.

Is there a way to group nodes with some shadows and labels while keeping them using GraphViz Original node layout?

This may not be a good answer, because it means a lot of trial and error, but at least You get the (I guess) invisible nodes you want:

digraph {
rankdir=LR;

subgraph cluster_level1 {
label = "Level 1";
style=filled;
color=lightgrey;
A01[ style = invis ];
A1;
A02[ style = invis ];
A03[ style = invis ];
A06[ style = invis ];
A05[ style = invis ];
B1;
A04[ style = invis ];
}

subgraph cluster_level2 {
label = "Level 2";
style=filled;
color=lightgrey ;

A21;
A22;
A23;
A24;

B21;
B22;
B23 ;
B24;
}

subgraph cluster_level3 {
label = "Level 3";
style=filled;
color=lightgrey;

A07[ style = invis ];
A31;
A32;
A08[ style = invis ];

B31;< br /> B32;
B33;
A01[ style = invis ];
A09[ style = invis ];
}

A1 -> A21 ;
A1 -> A22;
A1 -> A23;
A1 -> A24;

B1 -> B21;
B1 -> B22;
B1 -> B23;
B1 -> B24;

A21 -> A31;
A22 -> A31;
A23 -> A31;< br />
A23 -> A32;

B21 -> B31;

B21 -> B32;
B22 -> B32;

B21 -> B33;
B23 -> B33;
}

Output

enter image description here

I want to draw several related subgraphs in GraphViz. When I draw a simple node, it looks beautiful:

enter image description here

Resources:

digraph {
rankdir=LR;

A1- > A21;
A1 -> A22;
A1 -> A23;
A1 -> A24;

B1 -> B21;
B1 -> B22;
B1 -> B23;
B1 -> B24;

A21 -> A31;
A22 -> A31;
A23 -> A31;

A23 -> A32;

B21 -> B31;

B21 -> B32;
B22 -> B32;

B21 -> B33;
B23- > B33;
}

Since the nodes at the same level in several subgraphs are related, I want to group them and give it a label.
I tried to do it with clusters, but It “squeezes” the node:

enter image description here

Resources:

digraph {
rankdir=LR;

subgraph cluster_level1 {
label = "Level 1 ";
style=filled;
color=lightgrey;

A1;
B1;
}

subgraph cluster_level2 {
label = "Level 2";
style=filled;
color=lightgrey;

A21;
A22;
A23;< br /> A24;

B21;
B22;
B23;
B24;
}

subgraph cluster_level3 {< br /> label = "Level 3";
style=filled;
color=lightgrey;

A31;
A32;

B31;
B32;
B33;
}

A1 -> A21;
A1 -> A22;
A1 -> A23;
A1 -> A24;

B1 -> B21;
B1 -> B22;
B1 -> B23;
B1 -> B24;

A21 -> A31;
A22 -> A31;
A23 -> A31;

A23 -> A32;

B21 -> B31;

B21 -> B32;
B22 -> B32;

B21 -> B33;
B23 -> B33;
}

There are only two subgraphs, which is bad, but still not bad. But if I add more It will become more ugly and ugly.

Is there a way to group nodes with some shadows and labels, while using GraphViz to keep the original node layout?

This may not be a good answer, because it means a lot of trial and error, but at least you get what you want (I guess) invisible Nodes:

digraph {
rankdir=LR;

subgraph cluster_level1 {
label = "Level 1 ";
style=filled;
color=lightgrey;
A01[ style = invis ];
A1;
A02[ style = invis ];
A03[ style = invis ];
A06[ style = invis ];
A05[ style = invis ];
B1;
A04[ style = invis ];
}

subgraph cluster_level2 {
label = "Level 2";
style=filled;
color=lightgrey;

A21;< br /> A22;
A23;
A24;

B21;
B22;
B23;
B24;
}

subgraph cluster_level3 {
label = "Level 3";
style=filled;
color=lightgrey;

A07[ style = invis ];
A31;
A32;
A08[ style = invis ];

B31;
B32;
B33;
A01[ style = inv is ];
A09[ style = invis ];
}

A1 -> A21;
A1 -> A22;
A1 -> A23;
A1 -> A24;

B1 -> B21;
B1 -> B22;
B1 -> B23;
B1 -> B24;< br />
A21 -> A31;
A22 -> A31;
A23 -> A31;

A23 -> A32;

B21 -> B31;

B21 -> B32;
B22 -> B32;

B21 -> B33;
B23 -> B33;
}

Yield

enter image description here

Leave a Comment

Your email address will not be published.