views:

1443

answers:

2

I've got a list of objects that I need to organize as an aesthetic graph. My current approach involves IronPython and a genetic algorithm, but this takes way too long.

I've been reading up on Graphviz, QuickGraph and Graph#, but I don't need the visualization part - I already have an app that will display the nodes given the x/y coordinates. I've been told that both the Sugiyama algorithm and the force-based family of algorithms tend to output pleasing graphs, but I can't seem to find a .NET library that will output the coordinates instead of the image without some pretty severe sourcecode hacking.

Can anyone recommend libraries, algorithms or the like?

+1  A: 

Microsoft Research has an automated graph layout engine that might assist you in this effort.

You may read more about it here:

http://research.microsoft.com/en-us/downloads/f1303e46-965f-401a-87c3-34e1331d32c5/

Michael McCloskey
I tried GLEE/MSAGL, but it only outputs images AFAIK - do you know if you can get the coordinates?
hb
I was under the impression that the layout engine was independent of the rendering components, but I cannot state that with absolute certainty.This paper talks about the theory behind it, including the Sugiyama algorithm.ftp://ftp.research.microsoft.com/pub/tr/TR-2007-72.pdf
Michael McCloskey
+7  A: 

There are a number of options, with various pros and cons - you may want to sift through this which is a list of software that does, more or less, what you're looking for.

Basically, there doesn't seem to be a free, pure C# implementation that is intended to be used in capacity of layout engine library. The closest thing seems to be MSAGL, which is downloadable if you're on MSDN, but otherwise is fairly pricey.

The distinction between Graph# and QuickGraph is that the latter provides graph traversal and manipulation primitives but does not provide any layout algorithms. Graph# has all the source available, and from what I've (briefly) looked at, has a neat separation between layout engine and drawing implementation.

Graphviz is written in pure C/C++ and is fairly monolithic, taking as input a text file describing the graph and producing various types of output, both vector and raster based. It isn't a great fit as a plug-in layout engine, but could be used by shelling out and providing the requisite input file and parsing the output. Not a very clean solution though.

There's also something called OGDF. Although it's written entirely in C++, it has been designed to be used as a layout engine library and has a well-structured interface for this. It supports various layout algorithms including optimised Sugiyama if that's what you're interested in.

If you're interested in implementing an optimised variation on Sugiyama, you could always roll your own using a neat description of the algorithm :)

Ultimately though, you should probably decide what type of layout you're after before you make a decision on the library.

Eric Smith