Visualizing Code Execution
The Java CallGraph class offers a small set of methods for augmenting Java
code so that various forms of call graphs can be generated by utilizing
the GraphViz system.
Based purely on anecdotal evidence from using these call graphs during
teaching, this way of visualizing complex function calls (often involving
recursion) is of great help to new programmers. The ability to fine-tune
the types of information shown (calls, returns, and comments), and the
amount of information in each node, makes the CallGraph class a useful tool.
The paper included here describes the class using the Fibonacci function
as an example. There are also brief discussions of applying CallGraph to
the n-queens problem and mergesort.
The zipped file contains the source and many more examples.
- The "Visualizing Code Execution" Paper (596 KB). Last updated: 14th April 2019.
This describes the use of the CallGraph class.
- Zipped code (16 KB). Last updated: 14th April 2019.
This includes the source code for the CallGraph Java class,
and numerous examples.
- The CallGraph class generates text which is passed to the GraphViz system for processing, so you'll need to install a copy.
- The MS Windows installer for GraphViz 2.38 (34 MB).
I've added this link to an old version
of GraphViz since v2.44 seems to have some problems drawing "Return" box edges. The
dot command issues a warning about "flat edges between adjacent nodes", and
then fails to link those nodes into the graph.
Dr. Andrew Davison
Back to my home page