I'm trying to process and render some graph in DOT format. The dot file I have is large (~300MB), and it contains multiple digraphs
digraph 1 {...}
digraph 2 {...}
digraph 3 {...}
I have got 2 questions:
1. Is it possible to use render only 1 digraph instead of the whole graph?
Something like dot -3 -Tps mygraph.dot -o out.ps
to render digraph 3 only?
2.What's the best Python library to process dot format?(other languages are also acceptable)
Here are two I tried, but not good enough
pydot It gives me a digraph list after importing, which is good, but it doesn't handle "." in the node name. For example nd.nd [label="nd_node"]
will fail
pygraphviz It does handle ".", but only imports digraph 1 when given multiple graph definition in a file :(
Since you have dot
, you should also have gvpr
, a graph-processing tool. You can print the third graph with a simple gvpr
script, like so:
BEGIN { int count = 0; }
BEG_G {
count = count + 1;
if(count == 3) {
write($G);
}
}
Then, you can use this as a source filter:
cat mygraph.dot | gvpr -f thirdgraph.gv | dot -Tps -o out.ps