DAGVIZ examples using Dagre-D3

This notebook demonstrates drawing DAG's using dagre-d3.

Simple DAG

This example is taken from D3-DAG's example section. We start by importing DAGVIZ and constructing the DAG object. The DAG object is a simple wrapper around networkx's DiGraph.

Next we start adding nodes and edges.

Rendering the graph is as simple as you would expect it to be in Jupyter.

Linux kernel commit history

Let's try something a bit more challenging: the last thousand commits of the Linux kernel git repository (dated June 20th, 2021). I generated a git log for the linux kernel using

git log --oneline --parents > linux-git-log.txt

This gives a long list of lines like:

cba5e97280f5 9df7f15ee922 a7b359fc6a37 Merge tag 'sched_urgent_for_v5.13_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Where the first token is this commit hash, the subsequent hashes are parents, and the text is the summary.

The script below parses this log and turns it into a networkx graph:

As this graph is rather big, the rendering will take some time, and you will need to zoom and pan around a bit to find it, but the process is very simple:

Dagre features

The dagre visualization support non-string nodes...

and nodes and edges with labels: