Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
Graphviz 在我看来是最好的选择。
Graphviz 是首屈一指的图形渲染/布局库;它成熟、稳定、开源且免费。它不是一个专用的流程图或图表包,但它的核心用例——即由节点和边组成的对象的高效且美观的渲染,显然包含流程图绘制——特别是因为它的 api 允许用户设置各种 布局上的约束以鼓励以各种格式呈现——例如,您可以要求同一级别的所有节点(从根开始的相同数量的父节点)呈现在单个中心对齐的行中。
Graphviz 不是一个 Python 库(它是用 C 编写的);然而,有高质量的 python 绑定可用。
我最熟悉的 python-Graphviz 库是 pygraphviz,非常优秀。
另外两个是 pydot 和 yapgvb。我至少用过这两种方法几次。每个都比 pygraphviz 小(这可能是一个优势,具体取决于您的用例);此外,两者都没有像 pygraphviz 那样记录。
幸运的是,所有这三个 python 库都是 Graphviz 的薄包装器,因此没有一个库隐藏了轻量级、优雅的 Graphviz 语法(点语言)。
这是我用来创建小“的代码(使用 graphviz 的 dot 语言)流程图”如下:
Graphviz is the best option in my opinion.
Graphviz is the premiere graph rendering/layout library; it's mature, stable, open-source, and free of charge. It is not a dedicated flowchart or diagramming package, but its core use case--i.e., efficient and aesthetic rendering of objects comprised of nodes and edges, obviously subsumes flowchart drawing--particularly because its api allows the user to set various constraints on the layout to encourage rendering in the various formats--eg, you can require all nodes of the same level (same number of parents from the root) to be rendered in a single center-aligned row.
Graphviz is not a python library (it's written in C); however there are high quality python bindings available.
The python-Graphviz library I am most familar with is pygraphviz, which is excellent.
The other two are pydot and yapgvb. I have used both of these at least a few times. Each is smaller than pygraphviz (which might be an advantage depending on your use case); in addition neither is documented as well as pygraphviz.
Fortunately, all three of these python libraries are thin wrappers over Graphviz, so none conceal the lightweight, elegant Graphviz syntax (the dot language).
Here's the code (in graphviz' dot language) I used to create the small "flowchart" below:
和 doug 一样,我建议使用 Graphviz。
我还想提一下,您还可以直接用非常简单的 点语言 编写图表(然后可以使用Graphviz 或其他工具);这是使用 pydot 的更轻量级的替代方案,您的代码不依赖于任何模块。
Like doug, I would suggest Graphviz.
I would also like to mention that you can also directly write graphs in the very simple dot language (they can then be plotted with Graphviz or other tools); this is a more lightweight alternative to using pydot, with no dependency of your code on any module.
gprof2dot.py
可以自动分析和可视化程序中的执行流程。可以在 ActiveState 代码上找到reciple 578138。请注意程序末尾的批处理文件。gprof2dot.py
can automatically profile and visualize the execution flow in your program. It can be found as reciple 578138 on ActiveState Code. Please note the batch file at the end of the program.