I have a large Graphviz file where I have put different nodes and edges onto different layers. A number of nodes are grouped into a subgraph cluster.
This makes it easy to focus on the particular part of the graph that is important. However I would now like to extract each layer into its own DOT file automatically.
I've been using gvpr -i 'N[layer=="(*a*)"]' source.gv > a.gv
, which achieves what I want, by extracting the nodes and edges, but it fails to extract the subgraph, so I lose the context of the nodes.
For example, with the source graph:
digraph {
layers = "a:b";
layerselect = "";
subgraph cluster_alpha {
label = "Alpha";
a, b, c [layer = "a"];
}
subgraph cluster_beta {
label = "Beta";
d, e, f [layer = "b"];
}
g [layer = "a"];
h [layer = "b"];
g -> a [layer = "a"];
h -> e [layer = "b"]
}
Running gvpr -i 'N[layer=="(*a*)"]' source.gv > a.gv
results in the following output:
digraph gvpr_result {
graph [layers="a:b:c",
layerselect=""
];
a [layer=a];
b [layer=a];
c [layer=a];
g [layer=a];
g -> a [layer=a];
}
If you compare the output you will see that the box around nodes "a", "b", and "c" and the label "Alpha" is missing.
Do you have any suggestions on how I can use gvpr
to also output the subgraph clusters, or some other strategy to output the nodes, edges, and subgraphs of a given layer to a DOT file?