Click here to Skip to main content
11,631,710 members (75,266 online)
Click here to Skip to main content

Tagged as

.NET Code Dependency Graph Visualization using Force Field Simulation

, 11 Feb 2014 CPOL 6.1K 4
Rate this:
Please Sign up or sign in to vote.
Dependency graph is great visual way to examine code and understand the code base without having to look through it. There are number of powerful tools like Visual Studio Ultimate […]

Dependency graph is great visual way to examine code and understand the code base without having to look through it.
There are number of powerful tools like Visual Studio Ultimate Dependency Graphs or ndepend especially for .NET code.

Download: binaries

Our tool is a less sophisticated and less scientific way of viewing dependencies. Therefore it is more simple, intuitive and gives you better feeling of what “belongs together” and where are natural boundaries between components.

The Idea
We generate a dependency graph out of .NET assemblies, put it into a “force field” and see how nodes, representing types are wobbling around, until they found their “natural” places.


…and it’s interactive. You can poke your code dependencies:

  • Hover nodes to see details
  • Click namespace nodes to burst them
  • Try to drag nodes and see how much will be “taken along”
  • Expand/collapse the tree, expand/collapse a subtree tree using context menu
  • Check/uncheck tree nodes to highlight them on the graph
  • Use mouse wheel to zoom, drag the surface to pan

There are two executables. The first one codevis.exe generates dependency graphs out of assemblies and saves them into json files. Another one Gma.CodeVisuals.WebApi.exe is for visualization, which hosts a HTML5 site on port 8080 and launches the browser.

You can generate dependencies out of one or several assemblies. Note that if you generate one graph out of several assemblies it will also include inter-assembly dependencies, dependencies between types located in different assemblies.


    > codevis.exe C:\Framework\System.Core.dll
    > codevis.exe C:\Framework\System.Data*
    > codevis.exe MyAssembly System.Core System.Linq -p:C:\framework\;c:\myfolder

Assembly names must be separated by spaces. The ‘.dll’ or ‘.exe’ extension can be omitted. Wildcards can be used in names. You have also a choice between using absolute paths with every assembly or specifying short assmebly names together with search directories using the -p option.

For dependency graph generation we use .NET reflection and a library by Roy Osherove which has been originally adapted from Microsoft’s sample code for a DynamicMethod Visualizer.

Visualization is done using very powerful and beautiful library named D3 Data-Driven Documents. The CodeFlower visualizer, which is also d3js based and visualizes code base by means of LOCs, delivered us a good starting point.

The project is hosted at It is open source. Except improving the dependency graph usability we will probably add some other intuitive code metric visualizations. Currently am playing with idea to migrate my Code Word Cloud Generator into d3js and HTML5.

One more thing
I personally liked the idea of Web API and HTML5 site hosted in one exe very much. All you need is the reusable class WebServerOnFolder (under $\Gma.CodeVisuals.WebApi\Server\WebServerOnFolder.cs) and the ASP.NET Web API Self Host nuget package.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

George Mamaladze
Software Developer
Germany Germany
Tweeter: @gmamaladze
Google+: gmamaladze

You may also be interested in...

Comments and Discussions

QuestionError at github Pin
Anders Eriksson12-Feb-14 4:48
memberAnders Eriksson12-Feb-14 4:48 
NewsRe: Error at github Pin
George Mamaladze12-Feb-14 7:51
memberGeorge Mamaladze12-Feb-14 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150723.1 | Last Updated 12 Feb 2014
Article Copyright 2014 by George Mamaladze
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid