Coloured call graphs!

Juha Jeronen has added some features to the Python call-graph generator (pyan) I’ve previously blogged about. With a single command line, I can now get pictures like this: -c --dot | dot -Tpng > backup-use-and-def.png

A bit of colour always shows a program’s structure in a better light. Green for the backup program, orange and blue for high-level and low-level journal manipulation, and yellow for link creation.

As well as automatic colouring by namespace, there are options to control whether use- and define- edges are shown, and whether nodes in each namespaces are grouped together. For instance, instead of drawing define-edges between namespaces and their members as above, we could omit those edges and instead group them. The “fdp” layout algorithm seems to render best for this graph: -n -g -c --dot | fdp -Tpng > backup-use-and-group.png

Juha’s colour and grouping enhancements are implemented for the GraphViz output. pyan also outputs .tgf files for yEd. But “trivial graph format” is just too trivial to support these options, so I may soon extend the program to write the more advanced .graphml format.

This entry was posted in Programming and tagged , , , . Bookmark the permalink.

9 Responses to Coloured call graphs!

  1. Juha Jeronen says:

    Thanks for the post. Nice ‘screenshots’ :)

    By the way, I have now modified XDot, too. The new version comes with an incremental Find feature (handy for looking for nodes by label text), and highlights outgoing/incoming linked nodes (if modifiers held down) when hovering over nodes. It also has some new UI animations, the UI has been generally polished, and it has built-in documentation.

    I just posted about the changes to the original site ( ), currently waiting if there is an interest.

    Check it out (no pun intended) if you or any of the readers are interested. It’s available at:

  2. Juha Jeronen says:

    Update: my repository for this was getting a bit messy, so it has been reorganized. The modified Pyan and XDot are now both in their own subfolders:

    The top-level directory

    contains a combined README and a wrapper script ( for convenience.

  3. Pingback: More thoughts on version control | EJRH

  4. This is a brilliant project and I was so glad to find it! I’ve extracted the code from both your repositories into a single one that contains a history from each of your original commits, but not in the same repository as your other software … I hope that’s useful. It’s at:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s