Reputation: 487
I wrote a script that dynamically generates graphviz graphs, containing some clusters. I'd like to define the sort order of clusters, since when I visualize the graph, clusters are not always in the same order I defined them.
I tried to use "packmode" and "sortv" attributes, but maybe I understand bad their use. Here is a simple exameple, where I would like to have the cluster B on left, and cluster A on right:
digraph G {
pack=true;
packmode="array_u";
subgraph cluster_A {
sortv=2;
node [label="A1"] A1;
node [label="A2"] A2;
node [label="A3"] A3;
A1->A2;
A1->A3;
}
subgraph cluster_B {
sortv=1;
node [label="B1"] B1;
node [label="B2"] B2;
node [label="B3"] B3;
B1->B2;
B1->B3;
}
B1->A1 [constraint="false"];
}
How can I solve this trouble? Tnanks in advance!
Upvotes: 4
Views: 2687
Reputation: 1129
It's not perfect, but if you draw an invisible edge from cluster B to cluster A, it will place cluster B as a predecessor of cluster A, but a bit above:
digraph G {
pack=true;
packmode="array_u";
compound = "true";
subgraph cluster_A {
sortv=2;
node [label="A1"] A1;
node [label="A2"] A2;
node [label="A3"] A3;
A1->A2;
A1->A3;
}
subgraph cluster_B {
sortv=1;
node [label="B1"] B1;
node [label="B2"] B2;
node [label="B3"] B3;
B1->B2;
B1->B3;
}
B1->A1 [constraint="false"];
B1 -> A1
[
ltail = "cluster_B"
lhead = "cluster_A"
style = "invis"
]
}
Just add the compound=true
instruction and the invisible edge.
Upvotes: 2