Reputation: 93
I have a graph with 3 subgraphs that are placed one along the other, I want them to be stacked one on top each other (I don't want the direction of the content of the subgraph to change).
The simple example:
digraph G {
rankdir=TB;
subgraph cluster_lkg{
subgraph cluster_sentence_1{
"A1","A2","A3"
"A1" -> "A2"
"A1" -> "A3"
}
subgraph cluster_concepts_1{
"B1","B2","B3"
"B1" -> "B2"
"B1" -> "B3"
}
}
subgraph cluster_fkgs{
"C1","C2","C3"
"C1" -> "C2"
"C1" -> "C3"
}
}
Upvotes: 2
Views: 3632
Reputation: 7659
You need to connect the clusters (or, more precisely, the nodes within the clusters) in order to make your rankdir = TB
effective. You can do so by using invisible edges:
digraph G
{
rankdir=TB;
subgraph cluster_lkg
{
subgraph cluster_sentence_1
{
"A1","A2","A3"
"A1" -> "A2"
"A1" -> "A3"
}
subgraph cluster_concepts_1{
"B1","B2","B3"
"B1" -> "B2"
"B1" -> "B3"
}
//A1 -> B1;
}
subgraph cluster_fkgs
{
"C1","C2","C3"
"C1" -> "C2"
"C1" -> "C3"
}
edge[ style = invis ];
{ A2 A3 } -> B1;
{ B2 B3 } -> C1;
}
which yields
The node C1
is misaligned - I guess this comes from the nesting the clusters but I have no recipe against it. Hope it helps anyway.
Upvotes: 1