Skip to content

Conversation

@bvisness
Copy link
Contributor

You'll definitely want to squash the commits on this one :)

@mgaudet
Copy link
Contributor

mgaudet commented Oct 16, 2025

(Ben has asked that this not get merged until after he gets back)

Copy link
Contributor

@mgaudet mgaudet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very exciting.

One broad suggestion I'd give is: Perhaps indicate in some way which are -interactive- diagrams, and which are -not-.

});
</script>

We are not the first to visualize our compiler's internal graphs, of course, nor the first to make them interactive. But we were not satisfied with the output of common tools like [Graphviz](https://graphviz.org/) or [Mermaid](https://mermaid.js.org/), so we decided to create our own layout algorithm specifically tailored to our needs. The resulting algorithm is simple, fast, produces surprisingly high-quality output, and can be implemented in less than a thousand lines of code. The purpose of this article is to walk you through this algorithm and the design concepts behind it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're using the 'royal-we'... but this is all you! IMO it's OK to take credit here that you were the one who did all this work who built this, who created a new algorithm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll think about it, but in this quasi-academic context it feels weird to use the first person.

Copy link
Contributor

@mgaudet mgaudet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very excited for this to go up.


It is important to note that dummy nodes participate fully in this system. If for example you have two side-by-side loops, straightening the left loop's backedge will push the right loop to the side, avoiding overlaps and preserving the graph's visual structure.

We do not reach a fixed point with this strategy, nor do we attempt to. I find that if you continue to repeatedly apply these particular layout passes, nodes will wander to the right forever. Instead, the layout passes are hand-tuned to produce decent-looking results for most of the graphs we look at on a regular basis. That said, this could certainly be improved, especially for larger graphs which do benefit from more iterations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fixed-point (slight preference)

@bvisness bvisness merged commit 41d97aa into production Oct 28, 2025
4 checks passed
@bvisness bvisness deleted the iongraph branch October 28, 2025 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants