views:

78

answers:

3

I've got a list of objects (probably not more than 100), where each object has a distance to all the other objects. This distance is merely the added absolute difference between all the fields these objects share. There might be few (one) or many (dozens) of fields, thus the dimensionality of the distance is not important.

I'd like to display these points in a 2D graph such that objects which have a small distance appear close together. I'm hoping this will convey clearly how many sub-groups there are in the entire list. Obviously the axes of this graph are meaningless (I'm not even sure "graph" is the correct word to use).

What would be a good algorithm to convert a network of distances into a 2D point distribution? Ideally, I'd like a small change to the distance network to result in a small change in the graphic, so that incremental progress can be viewed as a smooth change over time.

I've made a small example of the sort of result I'm looking for: Example Graphic

Any ideas greatly appreciated, David


Edit:

It actually seems to have worked. I treat the entire set of values as a 2D particle cloud, construct inverse square repulsion forces between all particles and linear attraction forces based on inverse distance. It's not a stable algorithm, the result tends to spin violently whenever an additional iteration is performed, but it does always seem to generate a good separation into visual clusters:

alt text

I can post the C# code if anyone is interested (there's quite a lot of it sadly)

+1  A: 

Graphviz contains implementations of several different approaches to solving this problem; consider using its spring model graph layout tools as a basis for your solution. Alternatively, its site contains a good collection of source material on the related theory.

moonshadow
Thanks moonshadow, it *is* a good starting point. I'm not marking this as the answer yet, as I'm hopeful for some more links.
David Rutten
+1  A: 

Hi

You might want to Google around for terms such as:

  • automatic graph layout; and
  • force-based algorithms.

GraphViz does implement some of these algorithms, not sure if it includes any that are useful to you.

One cautionary note -- for some algorithms small changes to your graph content can result in very large changes to the graph.

Regards

Mark

High Performance Mark
+1  A: 

The previous answers are probably helpful, but unfortunately given your description of the problem, it isn't guaranteed to have a solution, and in fact most of the time it won't.

I think you need to read in to cluster analysis quite a bit, because there are algorithms to sort your points into clusters based on a relatedness metric, and then you can use graphviz or something like that to draw the results. http://en.wikipedia.org/wiki/Cluster_analysis

One I quite like is a 'minimum-cut partitioning algorithm', see here: http://en.wikipedia.org/wiki/Cut_(graph_theory)

Andrew McGregor
@Andrew, oh my, that looks awfully complicated. I foresee some further forays into clustering algorithms in my near future so thank you for these links, however I think the problem has been solved by a simple spring-charge system. It works fine on small and large data-sets and I can run about 500 iterations and still have the result be real-time.
David Rutten
Ok, if that gives satisfactory results, it's certainly simple.
Andrew McGregor