views:

1691

answers:

12

By graph here I mean something resembling these images:

The ideal solution would:

  • use only managed code
  • allow output to a bitmap image
  • allow output to WPF elements
  • include some kind of interactive surface for displaying the graph that supports zooming, panning and reorganisation of nodes

I'm also interested in hearing about projects that could potentially be used as the starting point for this kind of work. If it requires some development to achieve what I want, then I'm prepared to tackle it. The most complex portion of this goal seems to be obtaining the graph layout in a reasonable time frame.

+2  A: 

Microsoft Research provides a tool called MSAGL (Automatic Graph Layout, previously called GLEE) for .NET.

MSAGL is available here: http://research.microsoft.com/en-us/downloads/f1303e46-965f-401a-87c3-34e1331d32c5/default.aspx

Disclaimer: I haven't used the tool so I don't know whether it is suitable for you (and neither do I know about the licensing conditions, seems it is for non-commercial applications only). But at least it looks interesting.

0xA3
I used GLEE v1 before. It was free but pretty crude. The latest version (1.2) costs GBP 150 (USD 220). I'd like to hear about free solutions ideally.
Drew Noakes
BTW the project home page is here: http://research.microsoft.com/en-us/projects/msagl/default.aspx
Drew Noakes
NDepend use it, so I think the license allow commercial utilisation.http://codebetter.com/blogs/patricksmacchia/archive/2008/09/09/interactive-code-dependencies-graph.aspx
madgnome
@madgnome - Interesting. The last time I looked at NDepend, they seemed to be using GraphViz. I expect that once you've bought a license, you can distribute it with your app, but this seems to me the sort of thing that should be freely available somewhere, and maybe something I'd work on if not.
Drew Noakes
I had some more time to look at MSAGL and was disappointed. It was crashing out of the box with 10K nodes and 50K edges with an out of memory exception. For the MDS layout it looks like they optimized for CPU usage at the expense of memory.
Mike Post
A: 

Its not .NET, but an often referenced toolkit for rendering graphs is AT&T Graphviz. I've only used the free-standing applications myself, but the source code is available under something resembling an open source license.

Graphviz is used by the popular code documentation tool doxygen to automatically draw various diagrams for its generated documentation.

RBerteig
I used Graphviz in a .NET assembly dependency analyser I wrote a few years back. It's pretty straightforward but only outputs bitmaps or SVG, and requires an installation on the client, followed by COM interop. It's not bad, but not quite what I'm hoping for!
Drew Noakes
If anyone is interested in seeing some crude code that uses WinGraphViz via COM, see http://www.drewnoakes.com/code/dependancyanalyser/ ...the code is for VS2003 and it's a bit embarrassing to admit that the code is mine, but it gets the point across.
Drew Noakes
I suspect that replacing the guts of dot by porting it to managed C++ would be possible, but not easy.I use the command line tools to quickly sketch state machines and the like. Dot will output PostScript too, which meets my needs.
RBerteig
+1  A: 

The boys at Mindscape have such a tool

With the imaginative name WPF Flow Diagrams

Also, check out Vertigo's Family.Show demo project, it has a simple form of this

TFD
WPF Flow Diagrams costs USD 500 and doesn't do automatic layout of the graph. It does appear to have nice WPF integration.
Drew Noakes
The Family.Show application plots family trees which (usually!) are a simple subset of all possible graphs. They are acyclic, for example. I am interested in seeing algorithms that can lay out a wide variety of graphs such as the Sugiyama approach.
Drew Noakes
Actually their Star Diagrams product seems to have some sort of automatic layout. $149/seat and offers tree and force directed. I haven't used it and have no idea how it handles the general case, but this is more along the lines of what you're looking for than their Flow Diagrams product.
Mike Post
A: 

When I did some work involving graphs last summer I found the best option that wasn't overly expensive was to manually do it in SVG, i.e. write out an SVG file from a bunch of strings, and render that out to an image using Inkscape.

This is not a quick and easy solution, but it does allow for near-infinite customisation, so it might be nice if you have to organise the graphs or do spatial organisation based on connections etc.

Ed Woodcock
+3  A: 

Graphviz is still today, in my opinion, one of the best graph library there is. However, integrating it to .Net is a pain.

It is possible to call the command line tool to generate a shape output based on your graph input, then you read the output and lay the elements on a custom control that displays whatever shapes graphviz has calculated. It's very hacky but it's the best way our team have found of integrating graphviz with .Net a few years ago.

A better solution might exist today; at that time GLEE was still very embrionic and I haven't seen the progress Microsoft did since that time.

Coincoin
GraphViz can be called via COM using WinGraphViz, though the output must be written to a file and then read from the disk which is unfortunate. It also requires an extra DLL to be registered with COM (afaik) to get it working. The DOT syntax is simple and easy to work with too.
Drew Noakes
I didn't know about WinGraphViz, nice. This is basically what we did, we generated a dot, compiled it and parsed the output to our graph model.
Coincoin
Drew Noakes
WinGraphViz home page: http://wingraphviz.sourceforge.net/wingraphviz/
Drew Noakes
There is an option to have dot (and neato and friends) write .dot format output that includes the layout coordinates. Re-Parsing that to draw it wouldn't be too hard.
RBerteig
It's also possible to write a wrapper for graphviz so you may use "online" re-layouting and drag and drop. We did this once as "proof of concept", but there are still plenty of bugs inside.
Scoregraphic
A: 

not enough reputation to comment, however I have been playing on GLEE/MSAGL and the actual layout per se is good enough for what I need however I'd like to be able to have more control over what is actually inside the nodes rather than just a single value like now.

For example I'd like to have "details" that are hidden until I click on an expander in the node, or double click the node or hover with the mouse.

Assuming GLEE cannot do this are there now any pure .NET solutions available that could do it?

freddy smith
+1  A: 

Use QuickGraph to output Dot files for GraphViz. I did that in a recent project, and it seems to work quite well. Look here for sample code for parsing .plain files, or use my project here as a reference for just outputing .png images.

Jamie Penney
+5  A: 

Graph# is also another option. I haven't used it personally, but I've been meaning to get around to looking over it.

Jamie Penney
After a brief look, Graph# looks pretty interesting. Thanks for the link.
Drew Noakes
I haven't tried it yet, but unfortunately they claim the Sugiyama layout is buggy. That's the most useful layout in my experience, so hopefully it'll be patched up at some point.
Drew Noakes
Since my previous comment, it looks like this project has really come along (including Sugiyama layout). Haven't tried it yet, but next time I need something like this it will be the first lib I try.
Drew Noakes
Yeah after originally using GraphViz we moved to Graph# once their algorithm selection improved. I'm pretty happy with it so far, although I need to get round to making a patch for removing the random aspect to some of their layouts.
Jamie Penney
A: 

Northwoods offers a pure .NET solution in their GoLayout product. They offer tree, force directed, and layered digraph (which is not quite a Sujiyama effect, but not too far off for many if not most data sets). At $1790/seat it's expensive. There are also some limitations: most importantly, their implementations are designed for "human readable" graphs. I've given it data sets of over 5,000 nodes and had no issue, but I can also generate data sets of less than 500 nodes that cause it to have a stack overflow (recursing too deep). Depending upon your domain, it may (or may not) be a good fit. If you need a general layout package that handles any data set, I'd suggest GraphViz over Northwoods.

I have yet to use any of their WPF capabilities, but I know they have them. I've been using their stuff in WinForms land for a while.

Mike Post
+1  A: 

I have used MsAgl and it is pretty good. It also has viewers for both WinForms and WPF which may or may not be important to you. One does not have to use the viewers as they are quite loosely coupled to the graph layout engine.

It does not support everything that Graphviz does (notably in terms of some shape types). Also the documentation could be better but it is pretty solid if not the most polished MS product ever.

It does tick all of the items you mention as requirements, though the "on viewer" re-organization merely supports drag-moving nodes, re-routing edges and re-positioning labels. The graph does not respond to the movements of these elements by repositioning any other items.

Raoul
+3  A: 

I am working in the NDepend team and I confirm: we switched from GraphViz to MsAgl in september 2008 and also the MsAgl license allows indeed commercial utilisation.

Patrick Smacchia - NDepend dev
+1  A: 

I have used NodeXL, http://www.codeplex.com/NodeXL, which is a .Net 3.5 library (but also an Excel add-on). NodeXl is developed by Microsoft Research and pretty neat: it has visualization algorithms and some metrics but it is still in its early stages of development. If you have are a seasoned .Net developer then I would definitely take a look at it.

However, if you know Python then I would definitely recommend Networkx and its cousin pygraphviz which is an interface to Graphviz. I have used both and my productivity with Python / Networkx is way higher then when I was using NodeXL.

GLEE is Microsoft's closed source library that you only can use for free in non-commercial software while NodeXL is Microsoft's way of open source but you can use it freely in a product you develop.

DrDee
Thanks very much for this. I'll definitely check it out.
Drew Noakes