
Ask HN: How to visualize dependency graphs? - erlehmann_
My implementation of DJB redo [1] can output build dependency graphs that can be rendered with Graphviz. A recurring problem I have been having is that often, a target has many dependencies that share their dependencies, leading to unreadable graphs [2].<p>How could I create a readable dependency graph for such cases?<p>[1] http:&#x2F;&#x2F;news.dieweltistgarnichtso.net&#x2F;bin&#x2F;redo-sh.html
[2] http:&#x2F;&#x2F;daten.dieweltistgarnichtso.net&#x2F;pics&#x2F;graphs&#x2F;redo&#x2F;liberation-circuit-deps.png
======
PaulHoule
It seems to me you should be able to put an integer on each dependency so that
you can layer them in neat layers so the dependency arrows always point in the
same direction.

~~~
erlehmann_
I do not understand how your proposal would help. Could you elaborate on it
and provide an example or a quick sketch?

~~~
PaulHoule
How about this.

Give the "product" (which has nothing depending on it) the number 0, then the
number for anything else is the length of the longest chain of dependencies
from the root to the dependency in question.

You could put layer 0 on the far right, and then layer 1, layer 2 in vertical
rows going to the left for instance. The important thing is that the arrows
always point from right to left so they are not tangled. There are other ways
you could assign dependencies to layers that might look better or be more
informative but the "arrows always point the same way" property prevents
tangling.

Layout along the other axis is a different question, I'd imagine you could
shuffle the vertical order of the dependencies in the layers to minimize the
number of arrows that cross or something.

~~~
erlehmann_
The graph is already layered. It is precisely the crossings that are the
problem and minimizing them does not do a lot.

------
chris_va
Hard problem with spaghetti code, but you can try something like:
[http://bl.ocks.org/shunpochang/66620bad0e6b201f261c](http://bl.ocks.org/shunpochang/66620bad0e6b201f261c)

~~~
erlehmann_
You do not need to invoke “spaghetti code”. One file depending on lots of
other files that each depend on some library headers (e.g. the standard
library) results in these kinds of dependency graphs. See for example this
dependency graph for a roguelike written in C:
[http://daten.dieweltistgarnichtso.net/pics/graphs/redo/plomr...](http://daten.dieweltistgarnichtso.net/pics/graphs/redo/plomrogue-
dependencies.png)

