Graphviz 文档

发布于 2024-07-09 00:19:59 字数 1447 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

揪着可爱 2024-07-16 00:20:00

graphviz 是用于创建图形的非常非常简单的语言/格式。 如果能力足够你的话我会推荐它(它很简单,我估计学习时间最多1小时)。

The graphviz is very very simple language/format for creating graphs. If the capabilities are enough for you I would recommend it (Its so easy, that I would estimate the time to learn with at most 1 hour).

锦欢 2024-07-16 00:20:00

如果您只是谈论像 Doxygen 那样创建继承/协作图,那么值得研究可以自动为您完成此操作的 IDE。 对于从头开始或手动调整的文档,我使用 OmniGraffle (因为我使用的是Mac)我强烈推荐。

但是, GraphVizDOT 非常方便,不仅对于文档,而且对于调试和代码理解,特别是对于数据结构。 我通常不会手工编写 DOT,但自动生成的 DOT 非常值得付出最小的努力。

我发现 GraphViz 非常有用的地方之一是理解和调试二叉搜索树算法。 我开发了 CHDataStructures.framework,这是一个开源 Objective-C 框架,其中包括多种 BST 。 我实现了两种方法:在父类上实现了 -(NSString*)dotGraphString ,在每个子类上实现了 -(NSString*)dotGraphStringForNode: 。 在大约 30-40 行代码中(大部分位于 CHAbstractBinarySearchTree.m 的底部),我添加了迭代遍历二叉树并创建它的 DOT 表示的功能,包括平衡信息,将节点着色为红色或黑色等。(稍加小心,您就可以轻松表示空哨兵节点并以正确的排序顺序显示树。)

在我的测试代码中,每次修改树后,我调用 -dotGraphString 并将结果保存到 .dot 文件中,在此处设置断点,然后使用 GraphViz 打开该文件,GraphViz 足够智能,可以在文件更新时重新渲染 DOT 图形。 这种方法使我可以更轻松地查看树中发生的情况并发现给定算法实现中的错误。 这种方法可以相当容易地适应各种类型的数据结构,并且通常比创建仅用于可视化结构的 UI 更快、更容易。

If you're just talking about creating inheritance/collaboration diagrams like Doxygen does, it's worth investigating IDEs that will do that for you automatically. For from-scratch or hand-tuned documentation, I use OmniGraffle (since I'm on a Mac) which I highly recommend.

However, GraphViz and DOT can be really handy, not only for documentation, but for debugging and code comprehension as well, particularly for data structures. I generally don't write DOT by hand, but automatically-generated DOT can be well worth the minimal effort.

One of the places I've found GraphViz extremely useful is for understanding and debugging binary search tree algorithms. I develop CHDataStructures.framework, an open-source Objective-C framework, which includes several varieties of BSTs. I implemented two methods: -(NSString*)dotGraphString on the parent class and -(NSString*)dotGraphStringForNode: on each child class. In about 30-40 lines of code (most of it at the bottom of CHAbstractBinarySearchTree.m), I added the ability to iteratively traverse a binary tree and create a DOT representation of it, including balancing information, coloring nodes red or black, etc. (With a little care, you can easily represent null sentinel nodes and display the tree in proper sorted order.)

In my test code, after each modification of the tree, I called -dotGraphString and saved the result to a .dot file, stopped there with a breakpoint, then opened that file with GraphViz, which is smart enough to re-render the DOT graph when the file is updated. This approach made it vastly easier to see what was happening in the tree and spot bugs in my implementation of a given algorithm. This approach can be adapted fairly easily for various kinds of data structures, and is generally much faster and easier than creating a UI just for visualizing the structure.

枕梦 2024-07-16 00:20:00

Graphviz 不会为您提供像 Visio 一样流畅的图形界面。 然而,它会产生布局良好的图表。 我发现当我通过程序自动生成图形时(如 doxygen 的情况),它最有用。

Graphviz is not going to give you a slick graphical interface like Visio. It will however, produce well laid out graphs. I find it most useful when I am generating graphs automatically via a program (as in the case of doxygen).

戴着白色围巾的女孩 2024-07-16 00:20:00

Graphviz 对于以编程方式生成依赖图(通过点)最有用。 访客使用它来可视化网站访问; Hadoop/Cascading 使用它来可视化 Map-Reduce 作业的执行计划。

Graphviz is most useful to generate dependency graphs (via dot) programmatically. Visitors uses it to visualize site visits; Hadoop/Cascading uses it to visualize execution plan of map-reduce jobs.

赤濁 2024-07-16 00:20:00

我广泛使用 GraphViz 来编写文档,并且经常在外部使用 GraphViz 勾勒出关系或架构图,然后使用 @dot/@enddot 将它们添加到我的 Doxygen 代码中的额外页面中。 我最近还开始使用 @dotfile,它具有双重好处:将大点语句保留在代码文档之外,并允许我继续使用 GraphViz GUI 预览它们。

GraphViz 的另一大好处是简单的文本格式非常适合版本控制。 您可以在 git diff 中看到图表的更改,这对于任何二进制文档格式都是不可能的。 随着多年来我越来越多地使用它,这对我来说正成为一个更重要的功能。

然而,对于 UML,我使用真正的 UML 工具 (企业架构师),而不是在 Visio 中乱七八糟。

I use GraphViz extensively for documentation and often sketch out relationships or architecture diagrams using GraphViz externally then add them to extra pages in my Doxygen code using the @dot/@enddot. I've also recently started using @dotfile which has the dual benefit of keeping large dot statements out of the code docs and allowing me to continue to preview them with the GraphViz GUI.

The other big benefit with GraphViz is that the simple textual format works very well with version control. You can see changes to diagrams in your git diff which would be impossible with any binary documentation format. As I've used it more an more over the years, this is becoming a more important feature to me.

However, for UML I use a true UML tool (Enterprise Architect) rather than stuffing around in Visio.

踏月而来 2024-07-16 00:20:00

是的,graphviz 很容易学习,也很容易在程序中使用。

另请参阅 yEd,它是处理图表的好工具。 与 Visio 不同的是,它可以加载和保存各种易于手动编辑或编程生成的格式。 自动布局的东西也非常好。

Yes, graphviz is easy to learn and easy to use from within programs.

Also look at yEd which is a good tool for working with graphs. Unlike Visio, it will load and save a variety of formats which are easy to hand-edit or programatically-generate. The auto-layout stuff is quite nice too.

娇纵 2024-07-16 00:20:00

我偶尔用它来说明状态机。 graphviz 非常适合这一点。

I've used it occasionally for illustrating state machines. graphviz is perfect for that.

物价感观 2024-07-16 00:20:00

同意这里的共识; 我从 Graphviz 中获得了很多价值。 它非常适合创建简单或不那么简单的图表。 软件开发人员倾向于吸引图表,不仅在源代码中,而且在其他地方也是如此。

例如,现在在另一个浏览器窗口中,我使用 graphviz 图说明了我们组的分支和合并策略(使用 Confluence 插件 顺便说一句)。

Graphviz 也适用于 UML。 请参阅本教程; 这也是 Graphviz 的一个很好的介绍。

Agree with the consensus here; I get a lot of value out of Graphviz. It's really good for creating simple, and not so simple, diagrams. Software developers tend to attract graphs, not just in source code but elsewhere as well.

For example, right now in another browser window, I have our group's branching and merging strategy illustrated using a graphviz diagram (displayed using the confluence plugin BTW).

Graphviz is good for UML too. See this tutorial; it's a good introduction to Graphviz as well.

深海蓝天 2024-07-16 00:20:00

我们使用 graphviz 自动生成对象图作为 UML 验证工具的反馈。 我们对结果非常满意,因为我们设法提供图形结果,而无需担心布局。

We use graphviz to automatically generate object diagrams as feedback of our UML verification tool. We are really happy with the results since we manage to provide a graphical result without worrying at all about the layout.

落在眉间の轻吻 2024-07-16 00:20:00

我尝试过 Graphviz 好几次,但发现它的局限性很大。

我发现最适合手动文本输入图的是 Tikz
我将其用于 FSM

如果 Graphviz 输出满足您的要求特殊需求,可能没问题。
如果您对它的功能不太满意并且有一些 TeX 经验 -
看看Tikz。 那里有很多不同的软件包,你不知道
需要学习纯Tikz/PGF(看起来可能相当重)。

I had a go with Graphviz quite a few times, though found it quite limiting.

What I found best for manual text-entry diagrams is Tikz
I used it for FSM's

If Graphviz output satisfies your particular needs, it's probably fine.
If you are not quite happy with what it does and have some TeX experience -
have a look at Tikz. There many different packages out there, you don't
need to learn pure Tikz/PGF (which may seem quite heavy).

温柔戏命师 2024-07-16 00:20:00

供参考
使用 Graphviz 将 Microsoft Visio 插件添加到布局图:
http://www.calvert.ch/graphvizio/

FYI
Microsoft Visio addin to layout diagrams with Graphviz:
http://www.calvert.ch/graphvizio/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文