Fog Creek Software
Discussion Board




Source code dependency analysis?

I'm looking for a program that will automatically extract a dependency graph from a set of .cpp and .h files (e.g. A includes B includes C) and display the result in a nice 2D graphical format.

The purpose of this is to help me modularize my code a bit by seeing where things get too tightly coupled.

There must be tools for this... Free would be best but I'm willing to pay for really nice output.

(I found a little Perl script called "cinclude2dot" that almost does what I want, but it doesn't organize the graph into a logical hierarchy)

Dan Maas
Tuesday, May 07, 2002

GraphViz is an open source graphing program which can generate nice looking connected graphs.

http://www.research.att.com/sw/tools/graphviz/

Don't know if this is what you are after but here's an example to plot Module Dependencies from a program

http://www.research.att.com/sw/tools/graphviz/examples/undirected/softmaint.html

Matthew Lock
Tuesday, May 07, 2002

Thanks Matt... The cinclude2dot script I mentioned actually uses GraphViz to render its graphs - but unfortunately the results look rather messy (like the module dependency example you pointed to). I expected something more hierarchical, like the top two graphs on the GraphViz home page.

It may be that constructing a nice-looking graph from arbitrary .cpp and .h files is an impossible problem =). But I think not - it should be possible to assign a "rank" to each file that is the sum of the ranks of the files it includes, and then print a hierarchy based on said ranks...

Dan Maas
Tuesday, May 07, 2002

Getting a top down hierarchical (directed) graph or a graph that is just placed from the centre out is just a setting in GraphViz.

Check the DOT language http://www.research.att.com/~erg/graphviz/info/lang.html

using the setting digraph will give you a directed graph

Matthew Lock
Tuesday, May 07, 2002

Doxygen is what you're looking for.  It does this and much more.

www.doxygen.org

Robert Anderson
Tuesday, May 07, 2002

Check out Understand [ http://www.scitools.com/ucpp.html ].  They have a 30-day trial version (full version is $495) but I was very impressed by the analysis it generated, and it let me come up to speed pretty quickly on a massive existing codebase.

Dan Dunham
Wednesday, May 08, 2002

<< Check out Understand  >>

Right (they're running a beta-version of "Understand for Java" too).

I used "Understand for C++" for exactly the same purpose. Since it has C/Perl API - you can actually do many things with it.

Evgeny Goldin
Wednesday, May 08, 2002

*  Recent Topics

*  Fog Creek Home