Top
Best
New

Posted by pdubroy 10/29/2025

Who needs Graphviz when you can build it yourself?(spidermonkey.dev)
524 points | 108 commentspage 2
kiitos 10/29/2025|
this article is confusing, it appears to conflate graphviz (an umbrella term/tool that collects a set of layout engines and output formats) with both dot (a specific layout engine) and sstangl/iongraph (a specific tool that transforms a particular SSA/AST input format to a specific dot output format)

it also seems to conflate how a DAG is expressed, with how that expression is rendered

strange

colelyman 10/30/2025||
I feel like going to the source of an algorithm/implementation is a super power, as illustrated by this example.

Having used Graphviz for fairly complex visualizations I was initially shocked that someone would rewrite it themselves. Then I saw the breakdown of the algorithm and realized it may not be as complicated as I first thought.

All that being said, as a general rule it is hard to know what the hidden complexities may be until you are finished implementing the algorithm.

IshKebab 10/29/2025||
This is great. I've been trying to generate diagrams for HDL hierarchies and neither Graphviz nor ELK can do a remotely good job. In fact I've never got good results from Graphviz for any graphs over a handful of nodes. I think it just isn't actually very good. But it has such huge mindshare even if there was a better option I wouldn't be able to find it.
aqula 10/29/2025||
Layout is one of those things humans do so easily and intuitively, yet you couldn't write an easy algorithm for it. I wonder if there's potential to use gen ai to achieve human like results. Anyone has any thoughts on feasibility and complexity of such an approach?
pestaa 10/29/2025||
I dabbled in this area, there are poster layout generation attempts that use gen ai to come up with an initial layout plan, and even feed the visualization back into the llm for iterative fine-tuning.

I was intrigued, but couldn't make it work reliably. Perhaps I forgot to add "make it look nice" to my prompts.

https://arxiv.org/abs/2412.04237v3

https://haoyuchen.com/POSTA

https://github.com/microsoft/LayoutGeneration/blob/main/Layo...

aqula 10/29/2025||
Thanks for sharing. Although diagrams have a unique requirement that the boxes are inter-connected, and those connections must also look "nice".
HarHarVeryFunny 10/29/2025||
I think the hard part is more defining the different types of visually pleasing layouts that you want to support. What to align to what, what metrics to minimize, etc.

There is no single layout definition that looks good for all applications. What looks good for one type of graph data (flow charts, org charts, ASTs, family trees, etc, etc) may not look good for another.

Once you've reduced a desired type of layout to a set of layout rules, then I don't think implementing it is the bottleneck, and it seems this part could even be automated if wanted (e.g. evolve layout to best meet constraints).

eisbaw 10/29/2025||
Wow, thank you very much. I like the graphviz dot language. I may translate this to Rust.
OisinMoran 10/29/2025||
This is great! There are surprisingly few tools that actually output anything nice when it feels like such a doable problem.

One small improvement they could probably make is the ability to rearrange outputs at the bottom to reduce crossings. Just from the very first example it seems flipping the 0 and 1 outputs on the bottom graph would be nicer.

For anyone else interested in this general area, Steve Ruiz and Lu Wilson from tldraw often tweet a lot of fun nitty gritty edge cases in graph drawing.

bvisness 10/29/2025|
Resist this temptation. It is better for the true and false branches to always appear in the same order than to permute things to avoid edge crossings.
rs186 10/29/2025||
We looked at using Graphviz, but the copyleft nature of Graphviz license (Eclipse Public License) means that this will never be allowed in our company's software.
benterix 10/29/2025||
Interesting. The wiki says: "The Eclipse Public License is designed to be a business-friendly free software license, and features weaker copyleft provisions than licenses such as the GNU General Public License (GPL)."
rs186 10/29/2025||
Well, it's just they think it's business-friendly.

From EPL:

> If a Contributor Distributes the Program in any form, then: a) the Program must also be made available as Source Code, in accordance with section 3.2 ...

Except in startups that really embrace the idea of open source, no "serious" company will offer any portion of their source code under EPL license, even if that's just the modified/derived part of it. Not a chance.

For most companies, in reality, there are only two types of licenses -- copyleft and permissive, no middle ground. You either don't touch it with a 10 foot pole or do whatever you want as long as you copy and paste the attributions.

benterix 10/29/2025|||
So this basically depends on how you intend to use. All big corporations use tons of copyleft software, starting with Linux. But if your aim is to take a piece of software, modify it, and don't share your modifications, and this scenario makes you not to choose this particular project, then yes, the license is working as expected. Whether the net benefit of this is positive or not is another question.
kragen 10/29/2025||||
There are a pretty large number of "serious" companies that distribute code under the GNU GPL, which has similar but more stringent copyleft terms. IBM, for example, which also originated the Eclipse Public License, and TI, and ARM, and Apple. Almost every microcontroller vendor uses GCC.
rs186 10/30/2025||
I meant "product code" mostly, and of course you could say WebKit is part of a product and you'll be correct. My point is that it's the exception, not the norm. (Using "no company" was wrong on my end)
graphviz 10/30/2025||||
Don't most companies seek a supported product, like yWorks or Tom Sawyer Software in the case of graph layout?

Isn't the EPL "weak copyleft", so LGPL-ish? Would companies raise similar issues about glibc and GNU libstdc++? Just curious.

rs186 10/30/2025||
True, and in fact I am aware that other teams look for paid solutions where graphs power the core features of their products. For us, it is a small feature, so we were looking for the "least trouble" path.

I don't know enough about all those other libraries and their licenses, but I do know that as long as we don't ship those libraries, especially modified versions, it's likely ok (of course that's simplified). Some internal tooling depends on GNU tools but we are just users. For things like glibc, it's just a standard system library, so linking with it is not a problem. (I am sure legal has looked at this.)

But GPL/LGPL software is definitely the minority of software we use in any way. Basically they need to be avoided as much as possible.

hawk_ 10/29/2025||||
> if a Contributor Distributes

Doesn't this only apply to contributors and dev users?

kragen 10/29/2025||
I think it applies to anyone who distributes it; https://www.eclipse.org/legal/epl-2.0/ says:

    “Contributor” means any person or entity that Distributes the Program.
1gn15 10/29/2025|||
Can't you buy an exception to the license?
rs186 10/29/2025||
Not my call.
saagarjha 10/30/2025||
Your loss I guess
rs186 10/30/2025||
whatever, it's not the only graphics library out there. These days, almost for every software with copyleft license there is a permissive alternative, perhaps with the notable exception of Linux kernel.
anotheryou 10/29/2025||
looking at the spagetti: neither is readable, but I'd say wonky graphviz wins because you have a chance following some of the lines.

I love how bitwig solved it: gravity, color coding, stiffness, directionality (ins on the left, outs on the right).

https://polarity.me/img/bitwig-course-02-whatisthegrid-3.jpg

tunesmith 10/29/2025||
Wonder how it compares with elkjs? I had written a few things that wrapped dot, which felt clunky, but have since had good success writing react components that use elkjs. Elkjs has a stupid amount of configuration options, some of which aren't very clearly documented, but I've been able to get decent output for use cases like argument mapping and choose-your-own-adventure maps.
frumiousirc 10/29/2025|
Looks nice. Two things on my wish list:

1. Make graphs from Clang's AST.

2. Invent some style flourish to help follow an edge that becomes part of a bundle of many edges.

HarHarVeryFunny 10/29/2025|
If you can get the AST output into a text file, then it should be easy to convert it to the DOT input that GraphViz takes, which at heart is just a list of node connections (A -> B).
housel 10/29/2025||
"clang -Xclang -ast-dump=json" will take you partway there.
frumiousirc 10/30/2025||
The issue is to make sense of the incredibly detailed AST to answer various questions about the code base. For example, how to make an information flow graph that shows what functions read and write what variables in a set of C++ classes.
HarHarVeryFunny 10/31/2025||
This sounds like it might be a good use case for one of the LLM coding tools.

A pure AST wouldn't even have that information - it'd have the syntax, but not the semantics.

frumiousirc 11/1/2025||
I had tried this with the previous versions of sonnet and gemini pro. Sonnet's context, back then, could not hold the full source I was working on. Reducing the context did allow it produce a graph. Both LLMs produced graphs with enough omissions and errors to make the result not useful. In the end, I wrote an interpreter based on libclang to provide the semantics I needed for my particular case. That was not trivial for me (I have decades of experience with s/w dev, working with graphs, etc - but not compiler development). And I used LLM's help to do the development. The new type of semantics would require hard-coding new AST interpreter and graph construction. Repeating that all today with the better LLMs and after more practice driving them might produce something with less effort / more flexibility.

In any case, this experience gave me a new appreciation for compiler developers!

More comments...