Live data from Hacker News

Create diagrams with code using Graphviz

ncona.com

31–40 of 221 posts

Re: Create diagrams with code using Graphviz

#31
post #13

As much as I like Graphviz (and I've been using it for ages) I keep looking for an equivalent with two features: - Nicer, more modern looks (the original is too... LaTeX-y for my tastes) - A different layout engine that uses straight arrows and 90 degree turns So far I haven't been able to find any good replacements, although a few JS libraries come reasonably close.

Also I think graphviz is a great tool when you want to generate some diagrams quickly and don't care too much about the design. If you have a precise idea of how it should look, it is possible to force it to look that way but it becomes a lot of work (with a complex logic of clusters, ranks, groups, etc).

Re: Create diagrams with code using Graphviz

#33
Graphviz is almost deceptively bad. If I see a graph in a book; I expect it was made in TikZ.

TikZ isn't fun, but at least it has the flexibility to get a great looking image at the end of the process. The theoretical simplicity advantages of Graphviz usually get worn down by the fact that the diagrams look bad. Use PowerPoint, and if code is needed bite the bullet and struggle through TikZ.

Re: Create diagrams with code using Graphviz

#34
A couple of important tips that the article omits:

1. For manual editing, dot -Tx11 foo.dot displays the graph in a window and updates it automatically whenever you save. So you can have an editor window open and the dot window and see the results of every tweak. For automatically generated graphs, this provides you with a window that you can update by overwriting a file with a new graph description.

2. Although HTML nodes are more versatile, shape=record is much easier, and sufficient for a pretty wide range of diagrams.

For doing quick stuff by hand if you don't have Graphviz installed, or if you're stuck on a Mac without X-Windows, there's https://graphviz.christine.website/. I like Graphviz a lot; as other people point out, TikZ is capable of a wider range of graphics, and also you can write programs to generate graphs in TikZ. But Graphviz is often enough.

A really simple graph like https://graphviz.christine.website/#digraph%20G%20%7Ba-%3E%7... is sometimes good enough without further tweaking, but for, e.g., the top diagram in https://github.com/kragen/dumpulse#dumpulse-an-embeddable-du..., you usually have to tweak stuff a bit.

Re: Create diagrams with code using Graphviz

#35
post #30
post #7

I like graphviz a lot, but I almost always end up using [Tikz]( http://www.ctan.org/tex-archive/graphics/pgf/ ), which is quite a bit more flexible. One huge advantage of Tikz is that you can use LaTeX equations natively. E.g. subscripts and superscripts in graphviz involve jumping through a few hoops, iirc.

Does it have graph-drawing included?

Yes, part of TikZ is a clone of Graphviz, but implemented in LaTeX.

Re: Create diagrams with code using Graphviz

#36
post #30
post #7

I like graphviz a lot, but I almost always end up using [Tikz]( http://www.ctan.org/tex-archive/graphics/pgf/ ), which is quite a bit more flexible. One huge advantage of Tikz is that you can use LaTeX equations natively. E.g. subscripts and superscripts in graphviz involve jumping through a few hoops, iirc.

Does it have graph-drawing included?

That's one of its main uses. One thing it does not do (or I don't know how) and graphviz does, though, is arranging nodes intelligently so as to minimize clutter and edge distances. That's one of the nice things in graphviz.

Re: Create diagrams with code using Graphviz

#37
post #13

As much as I like Graphviz (and I've been using it for ages) I keep looking for an equivalent with two features: - Nicer, more modern looks (the original is too... LaTeX-y for my tastes) - A different layout engine that uses straight arrows and 90 degree turns So far I haven't been able to find any good replacements, although a few JS libraries come reasonably close.

> A different layout engine that uses straight arrows and 90 degree turns It's not a property of the engine but of the graph itself: http://www.graphviz.org/doc/info/attrs.html#d:splines https://stackoverflow.com/a/9055243

[deleted]

Re: Create diagrams with code using Graphviz

#38
post #13

As much as I like Graphviz (and I've been using it for ages) I keep looking for an equivalent with two features: - Nicer, more modern looks (the original is too... LaTeX-y for my tastes) - A different layout engine that uses straight arrows and 90 degree turns So far I haven't been able to find any good replacements, although a few JS libraries come reasonably close.

I was thinking that a d3 implementation would help with this, except for the 90 degree, and found a project [0].

It’s not a force directed graph, but does seem to me to look better. And since the output is javascript it can be styled and formatted as you like it.

[0] https://github.com/magjac/d3-graphviz

Re: Create diagrams with code using Graphviz

#40
post #30

Earlier quoted context omitted.

Does it have graph-drawing included?

That's one of its main uses. One thing it does not do (or I don't know how) and graphviz does, though, is arranging nodes intelligently so as to minimize clutter and edge distances. That's one of the nice things in graphviz.

> One thing it does not do (or I don't know how) and graphviz does, though, is arranging nodes intelligently

That's exactly what "graph drawing" means [0]. Can tikz choose the position of the vertices itself or you have to specify the positions yourself? If it is you who chooses the positions, then tikz does not do "graph drawing".

[0] https://en.wikipedia.org/wiki/Graph_drawing

Post reply on HN