I have some dot files (digraphs) that I need to read in Python and extract some values from the nodes to populate my data structure. I see there are two graphviz packages for Python: graphviz and pygraphviz. Is there any big difference between the two? From a quick scroll of the docs, they pretty much seem to do the same thing. I'll be using this in Python 2.7.X for the aforementioned task.
17
votes
perhaps useful too: qr.ae/pGtb7r
- Charlie Parker
perhaps also useful: github.com/pygraphviz/pygraphviz/issues/346 and python.libhunt.com/compare-pydot-vs-pygraphviz and github.com/pydot/pydot/issues/262
- Charlie Parker
I don't understand, why does pygraphviz and graphviz BOTH exist as python packages? What is pygraphviz doing that graphviz didn't already do? why would I choose pygraphviz vs graphviz for python?
- Charlie Parker
1 Answers
24
votes
graphviz is a lightweight library which calls graphviz as a subprocess to execute all actions and produce output. This library is great as a quick and easy way to produce SVG or PNG output.
pygraphviz contains complete C bindings which uses graphviz as a library and expose all of graphviz's internal functionality like add/remove nodes/edges. But it comes with higher complexity in deployment as pip needs to compile C bindings and find all libraries.
In your case, as you need to read and manipulate dot files, it looks like you have to go with pygraphviz. Other interesting alternative to take a look is http://pypi.python.org/pypi/pydot which is a pure python dot parser.
Disclaimer: I am biased, because I contributed (a little bit) to pygraphviz.