Top
Best
New

Posted by pdubroy 10/29/2025

Who needs Graphviz when you can build it yourself?(spidermonkey.dev)
524 points | 108 comments
zvr 10/29/2025|
To be more accurate, the comparison is not with Graphviz, but with dot(1).

Graphviz is a visualization framework and it includes many layout engines, implementing different algorithms: dot, neato, fdp, sfdp, circo, twopi, ...

It would be great if this new custom algorithm were to be contributed to Graphviz.

fulafel 10/29/2025||
It's a bit confusing. Dot apparently is both the language name [1] for the Graphviz syntax, and one of the layout engines [2], possibly with different capitalizations.

[1] https://graphviz.org/doc/info/lang.html [2] https://graphviz.org/docs/layouts/dot/

embedding-shape 10/29/2025|||
I've used GraphViz/Dot (I call `dot` in my terminal, but the package to install is `graphviz`) for probably two decades at this point, and what is what is still not clear to me, kind of like the whole imagemagick/convert thing which is similar, at least to someone on the outside.

Not sure why they can't come up with new names, use those, then when you invoke the program in the terminal, call the binary the same thing, instead of mucking about with calling everything differently, except some things, that share names.

zvr 10/29/2025|||
> Not sure why they can't ...

This is exactly what they have done. You can call "dot" and it runs the dot layout engine, but you can also run "neato", "sfdp" or any other -- with the same input.

The "graphviz" package installs all these executables.

stronglikedan 10/29/2025|||
At least Imagemagick came to their senses and renamed their command to magick (with convert still aliased for BC).
wswope 10/29/2025|||
I can see how you got that impression and don’t fault you for it in the slightest, but that’s not accurate.

It’s not the language name for all Graphviz syntax; it’s only the syntax for renderings made with the dot engine. Each engine has its own DSL, basically.

Someone 10/29/2025||
> Each engine has its own DSL, basically.

Does it? There are slightly different DSLs for directed and non-directed graphs, some features only work with some output formats, but AFAIK, everything in the DSL in independent of the layout engine.

a_e_k 10/29/2025|||
You can also set:

    layout = neato;
in a dot file, call dot, and it will use the neato layout engine.

(See https://graphviz.org/docs/attrs/layout/)

And if I look in my /usr/bin, I see that neato is just symlinked to dot. It's pulling the usual trick of one executable that behaves slightly differently depending on the invocation name.

wswope 10/29/2025|||
Looking at the docs again with fresh eyes, I think you and fulafel are on the money.

The specific engine syntaxes are by & large mutually incompatible, but DOT does seem to be the label used for the overall lang as well as the dot-engine-compatible dialect.

graphviz 10/30/2025||
Various tools use tool-specific graph attributes. For example, "rank" and "minlen" mean something to the hierarchical or layered graph layout tool (dot) but not to other layout tools. "size" and "label" are the same in all the layout tools. They all use the same underlying graph representation library with a parser generated by yacc or bison.

The documentation includes a big table of attributes that graphviz tools recognize.

With the availability of LLMs, there is better automated support now to find features that are needed. Just imagining here, but "make the layout fill the available space" or "make all the nodes look like points with associated text labels" (not sure if that even works but it should).

bvisness 10/29/2025|||
I’m not sure how far you can push the generality of the iongraph algorithm. My gut is that it could be made to work somewhat well for any control flow graph with reducible control flow, but I expect there would be many complications.
bvisness 10/29/2025|||
To get more precise, we benefit from knowing the nesting depth of each block. This plus reducible control flow is enough to reliably find loops. We also know exactly which edges are loop backedges; it’s easiest when these are explicitly annotated but perhaps it would be possible to derive that info from other loop info. (In Ion we have a dedicated “backedge block” per loop, which makes it obvious what we should do, but which other compilers likely wouldn’t have.)
dgently7 10/30/2025|||
There are also a bunch more available information channels that this doesn’t use that could communicate more information. Color, shape, pattern line type, “backdrops”/groups could all be implemented to provide additional visual clarity on any range of parameters you might care about.

I used to use the dcc application Nuke and it had some very complex graphs but the different nodes were all color coded so zooming out you could get a good idea of what was happening where just from the average color of a section.

It didn’t have an auto layout algo as good as this though.

sevensor 10/30/2025|||
What I really like about the article is the reflection on the limits of optimization. Optimization gets you mostly OK results most of the time, but there will always be pathological cases where optimization gives you bad results, and there’s often room for drastic improvements of you’re allowed to make stronger assumptions.
rurban 10/29/2025||
Yes, that would be great. Iongraph is MPL, graphviz is EPL. But Iongraph is Javascript anyway, so you would need to use Claude to translate it to C
Ghoelian 10/29/2025||
Why would you need Claude for that?
bvisness 10/29/2025|||
Everyone knows it is impossible to translate 1000 lines of JS to C in a reasonable amount of time. I mean, 1000 lines is kind of a lot, you know?
jasonm23 10/30/2025||||
"Need" is a bad word ... and ymmv
rurban 10/29/2025|||
Kimi is also good. New habits, you know
ctenb 10/29/2025||
This is a cool example of how specializing a generic algorithm to a specific subspace can yield much better results. This is quite often the case in my experience, but we often don't bother utilizing properties that are specific to our problem space, and just apply the generic algorithm out of convenience (and because it is often good enough)
lasfter 10/29/2025||
I wrote my thesis on this! Application-specific system design can get you orders of magnitude performance improvement, as well as better scalability/fault tolerance properties. I focused on graph analytics, but it's reasonable to think it applies more broadly.

Definitely true that application-specific design is often not worth the investment though. Chasing that 1000x improvement can easily cost you a year or two.

Adrock 10/30/2025||
Can you please link to your thesis? This sounds very interesting.
lasfter 11/8/2025||
Here it is:

https://scholar.google.com/citations?view_op=view_citation&h...

j2kun 10/29/2025||
Came here to say this, but with caveats. The particular domain has extra properties that allow their "stupider" algorithm to work better in their case. But a general graph drawing system has to deal with the inherent generality of the domain.

Usually there is a good middle ground: heuristic analysis of the input to see if it fits well with special-case "stupid and fast" algorithms, and sophisticated optimizations that are the fallback and work for everything and come with guarantees.

kylereeve 10/29/2025||
That's how all application-specific specializations work though, take advantage of domain properties that make you need a less generic algorithm.
le-mark 10/29/2025||
This is a great write up and thank you to the author! Just a note that graphviz dot is not purely Sugiyama’s, there is a paper on the site that details the actual implementation.

Also judging from the final two images (dot vs iongraph for the same large graph) it’s clear that dot is optimized for minimal area where iongraph does not. That’s the trade off. The author claims one is more easy to navigate than the other, I think that’s debatable.

Ultimately I found that visualizing large graphs is rarely helpful in practice; they can certainly look nice for some well defined graphs, but I rarely saw well defined graphs in the wild. Ymmv but maybe some would agree?

dfabulich 10/29/2025||
Visualizing large graphs is a "tarpit idea," one that initially seems appealing but never succeeds in practice.

Fundamentally, the problem is that visual aids can only really represent a few dozen things before they become as complicated as the thing you were trying to understand in the first place.

And when analyzing messy node diagrams, it’s not just the nodes we’re trying to visualize, but the lines connecting the nodes (the “edges”). We can only visualize a few dozen of those, and that typically means we can visualize only a handful of nodes at a time.

Visualization only works in trivial examples where you don’t need it; it fails in complex environments where you need it the most.

somat 10/30/2025|||
This is my problem with node based editors, the one I am most familiar with being blenders shader editor. I mean, sure, I guess it represents the internal structure. But it always feels so messy. Sometimes I wish blender would just let me work with a netlist.
jasonm23 10/30/2025||||
There's a threshold, of both user ability and scale of 'problem'

I mostly agree with you dfabulich - the repeated efforts to create node/pipeline tools "visual programming languages" are not built for us, and feel redundant.

But I took issue with "where you don't need it" as this is very much dependent on who "you" is.

taeric 10/29/2025|||
I would go further. The fundamental problem is the idea that there is a fundamentally correct representation of something. This actually goes further than even the visualization of the graph. Symbolic representations have the same trap.
bvisness 10/29/2025|||
I agree that we haven’t gained much yet from looking at large graphs. Usually we can reduce any problem of interest to something small. Still, Graphviz produces very ugly results even for small graphs, whereas this is where iongraph shines.

To be clear, what I think makes the latter graph more readable is particularly that the wires are easier to follow. Yes, it’s subjective, but backed up by my own personal experience. Long term I think we can add more interactive features to help us in such cases, e.g. search and dimming irrelevant wires.

taeric 10/29/2025||
I confess I found the graphs GraphViz made for me in https://taeric.github.io/many_sums.html oddly pretty. :D
jerf 10/29/2025|||
"Ultimately I found that visualizing large graphs is rarely helpful in practice; they can certainly look nice for some well defined graphs, but I rarely saw well defined graphs in the wild."

Yes, I'm with you: https://jerf.org/iri/post/2025/on_layers_and_boxes_and_lines...

Since writing that I'm finding my frustration at the inability of diagrams to link out or be linked into is growing. In hindsight it seems a super obvious way of using diagrams in a useful manner and nothing supports it worth a crap, even things that really ought to like Mermaid (which permits out links in text but holds it at arm's length (requiring you to set the diagram to "unsafe"[1]) and as near I can tell in a quick search never mentions this as a thing you can do in its docs, and still has no particular support I can find for linking in to a graph). This has turned into a "can't unsee" for me.

(Obviously I have not used every diagramming solution ever, so maybe there is something out there that supports linking in and/or out, and I'd love to hear about it... however, bear in mind I'm looking for what you might call "first class" support, that is, a feature clearly considered important in the design phase of the project, not the sort of accidental-combination-of-features accidental support that Mermaid half has, if you flip some obscure settings to "lower security" somewhere.)

[1]: https://stackoverflow.com/questions/41960529/how-to-add-a-li...

kiitos 10/29/2025|||
> There are three basic types of “boxes and lines” (as I derisively refer to them) diagrams:

the point of a boxes-and-lines diagram is to express relationships between components at a single layer/level of abstraction

the best metric for the "quality" of a diagram isn't the number of boxes, rather it's the number of edge-crossings, where >0 is a pretty reliable signal that either (a) the diagram is trying to show too much, or (b) the architecture is sub-optimal

any non-trivial system will always require multiple boxes-and-lines diagrams to be accurately described, one per abstraction-layer

and not really sure that linking between diagram and code is a core requirement, diagrams will generally include identifiers that are unambiguously grep-able, i guess...

jesuslop 10/29/2025|||
Enterprise architect ($$) had that buried in the gui, and wondered for long if obsidian canvas could do the same, reports wanted.
jesuslop 10/29/2025||
Yep, agreed. CMake does deps graphviz (been there), that is better than nothing. But big diagrams need support for exploding subdiagrams and going back.
lexh 10/29/2025||
This is a great write up.

I wonder if any of these techniques turn up in whatever the magic sauce is in D2’s TALA layout engine, which is in a league of its own IMO.

https://d2lang.com/examples/tala/

dllu 10/29/2025||
For those who are interested, the Will Evans course on graph drawing [1] covers a lot of cool graph drawing algorithms. Graph drawing is very interesting and many applications get it wrong. I once contributed [2] some small bugfixes to the Dot lexer for the Open Graph Drawing Framework, which has fast implementations of some amazing graph drawing algorithms, and my experience is that the OGDF draws graphs vastly better than the various algorithms in GraphViz (fewer crossings, faster, etc).

[1] https://www.cs.ubc.ca/~will/536E/

[2] https://github.com/ogdf/ogdf/pulls?q=is%3Apr%20author%3Adllu...

realityfactchex 10/29/2025||
The greatest thing about Graphviz is indeed the dot language. A nice thing about using dot is that the graph definition is *portable among all applications that support dot*.

Dot is such a simple and readable format (particularly if using the basic features). Thus, it can make a ton of sense to define graphs in strict dot, even if you will be rendering with another tool than Graphviz.

These days, there are other popular options, too -- Mermaid, etc, as TFA indicates. Nonetheless, Graphviz/dot will remain for the long haul, IMO, because dot is so, so good.

So, you need Graphviz for its syntax definitions primarily, and because it is a standard that could be recognized/run anywhere.

bvisness 10/29/2025|
"I love the status quo! My favorite thing about it is that it is the status quo."
nirava 10/29/2025||
anyone working on this space easily gets a +1!

I have struggled with code to diagram tools for a while [mermaid and graphviz], and usually return to figjam when I need the readabilty and aesthetics.

graph-viz is MASSIVE and a binary. mermaid requires the browser's svg rendering system to work. I just need something that builds diagrams from description easily ...

benterix 10/29/2025||
The problem with all these tools is that any diagram becomes unreadable past a certain number of nodes. So we need a higher amount of control over the compromise that is inherent in these scenarios. The approach taken by the author is a very good step in this direction and hopefully others will follow.
a_t48 10/29/2025|||
I used mermaid for https://basisrobotics.tech/2024/11/24/basis-robot-02-softwar... (autogenerated) and it worked out pretty well, but notably I wasn't trying to handle loops. There have to be mermaid to png renderers out there. Beyond that, I view svg/html output as a huge advantage - I can restyle it and it's copyable.
nirava 10/29/2025||
Mermaid is great in its niche, and being web-first has been its greatest asset. But that is also a great frustration because anytime I try to do anything out of the web-world with mermaid, it becomes a massive PITA thanks to needing a full headless browser.

I used graphviz to generate graphs for code structures, and that worked out great.

https://niravko.com/blog/visualize-cpp-data-structures#resul...

rapnie 10/29/2025|||
You might also check out D2, which had a recent run on the HN front page.

https://news.ycombinator.com/item?id=45707539

tauchunfall 10/29/2025|||
>graph-viz is MASSIVE and a binary. mermaid requires the browser's svg rendering system to work.

I succeeded to use resvg-js [1] with dagre/graphlib [2] to render graphs. resvg-js uses a 4 MB node library to render SVGs. dagre is used by mermaid for graph layout (for some of the diagram types). if you disable loading system fonts in resvg-js it just takes milliseconds to render the SVG.

I know that mermaid is well-known and very useful, but I don't like the code quality (especially consistency) and the bloat of dependencies. Last time I went through the code I assessed it requires significant refactorings to make it work with resvg-js, i.e. server-side graph layout and rendering.

There is also nomnoml [1], which is so great, it should deserve at least the same amount of attention as mermaid. the nomnoml codebase is a joy to read. the author even converted the dagre/graphlib codebase to typescript [4].

[1] https://github.com/thx/resvg-js [2] https://github.com/dagrejs/dagre [3] https://github.com/skanaar/nomnoml [4] https://github.com/skanaar/graphre

---

Edit: One of the refactorings to make mermaid work with resvg-js is related to measuring svg text width. It's needed to determine the width of the graph node boxes. mermaid needs to be able to also use `resvg.getBBox()` to make it work with server-side rendering.

kragen 10/29/2025|||
Surprised by your comment, I took a gander at graphviz; it's about a quarter of a million lines of code if you discount lib/sparse/color_palette.c and lib/edgepaint/lab_gamut.c, which are hundreds of thousands of lines of data values. This is much more than I expected.

If you want something that builds diagrams from textual descriptions, you might want to check out TikZ, which includes a subset of graphviz but also lets you draw anything you want. See https://en.wikipedia.org/wiki/PGF/TikZ. On the other hand, you won't have the rapid visual feedback you get with WYSIWYG drawing editors like FigJam.

aqula 10/29/2025||
I've had good results using ELK for a terraform diagram generator. You can see some samples here.

https://marketplace.visualstudio.com/items?itemName=infragra...

xlii 10/29/2025||
This is a concept I'm working around with Microdiagram (microdiagram.com) prototype.

i.e. having a general purpose diagram/graph layout is hellishly difficult, but most of the diagrams/charts follow much simpler rules, thus it's much easier to have N languages, each for 1 type of diagram, than 1 language for N types of diagrams.

nyrikki 10/29/2025||
While I fully support your efforts to make better tooling, UML is the poster child for this.

I highly encourage people working in this space to revisit those lessons.

Obviously if you find a new way to work around the limitations please run with it.

But limited scope, and targeted simplifications is the only way I have found, over application by trying to describe everything almost always ends up being more harmful in my experience.

xlii 11/11/2025||
Sorry for the late response but I just noticed your comment. I know UML and studied it for decades along with other diagramming solutions and this is something exactly opposite I aim for.

UML was made as a specification-through-visuals tool and I'm aiming at diagrams-as-communication tool. I.e. sure you can save them, but the use case I aim is that you hop on the video call, share screen and discuss specific concept with one of the diagram types.

Collaboration is a huge part of it, but since I've never seen my concept in realization I'm going to keep it hush-hush for a while :)

JohnKemeny 10/29/2025||
Sounds intriguing. What is an example of a chart and its language that you have designed so far?
xlii 10/29/2025||
The Piano chart on prototype is an example, that's for discussing piano keys and chords on basic level.

I already implemented (in other prototype) diagram for event calculus (i.e. consideration of event stream through addition of new events like rollback, modify etc.)

On paper I have designs for point-in-time designs, scenario divergence and also some fun ones like a bingo card template. Diagrams are one thing, but there's also a design for collaboration and play-replay capabilities.

That being said, that's only a design right now with a simple prototype on the website :)

zem 10/29/2025||
I would love to see this evolve into a more general purpose control flow graph viewer - pretty much any language implementation would find it a great debugging tool. it's probably most of the way there already.
stefs 10/29/2025|
this tool works by replacing the "general purpose" algorithm by specializing it, which made it less general purpose but simpler and more efficient ... and now there's the request to make it more general purpose.

(it's a joke! and the joke is that those are two different general purpose. but still.)

whizzter 10/29/2025||
I do get the joke but it's a tad misplaced here.

Language developers really do struggle with debugging our data-structures since they are often both circular and complex compared to many other applications, I wrote yet-another-UI tool for inspecting code back when I was doing my thesis work.

Maybe I should brush it off (and make it general... ), it would give you a source-code view and navigating the source-text you would be shown compiler nodes related to the lines/statements.

It was almost the only way to make sense of it since I was often generating multiple paths per statement (It was a lossy type-inference system so previous type branchings could lead to multiple subsequent code-paths through each statement and expression).

thw_9a83c 10/29/2025|
Nice work! The examples look better than the Graphviz output, indeed. This is a good example of how you can always beat a long-developed, generic tool by specializing for a much narrower use case.
More comments...