Graphviz vs PyGraphViz

为君一笑 提交于 2019-12-05 16:44:34

问题


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.


回答1:


graphviz is lightweight library which calls graphviz as subprocess to execute all actions and produce output. This library is great for quick and easy producing SVG or PNG output.

pygraphviz is complete C bindings which uses graphviz as library and expose all graphviz 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 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 it is pure python dot parser.

Disclaimer: I am biased, because I contributed (a little bit) to pygraphviz.



来源:https://stackoverflow.com/questions/37353199/graphviz-vs-pygraphviz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!