views:

201

answers:

5

In working on a shortest path algorithm across a network I would like to generate a picture of the network. I'd like to represent nodes (circles), links (lines), cost to traverse the link (number in the middle of the link line), and capacity of the link (number on the link line next to the node it represents) in the picture. Is there any library/software out there that would help to automate creating this picture?

I can do this manually in Visio or with some drawing application but I'd like to generate them from code as I change/tweak the network.

+4  A: 

If you're using python, Nodebox draws pretty graphs.

Corey
A: 

There are a bunch of visualizations of various algorithms here: Algorithmics Animation Workshop

Elie
This has nothing to do with what he wanted. He wanted to draw an image based off the currents state of his graph. You linked to a website that visually shows how some algorithms work.
Simucal
There is also pseudo-code attached to the visualizations.
Elie
Plus it could give him some ideas as to how he may want to go about building his visualizations. With all those examples of algorithms visualized, I'm sure he can think of ways to tweak one or two of them to do exactly what he wants.
Elie
A: 

Did you by chance check out the R programming language? I'm not positive but I believe that you can make images and such out of graphs. r-project.org

ParseTheData
+7  A: 

Sounds like a job for GraphViz , it generates graphs from a short text description file. I've used it to produce connected node graphs and I believe it should be possible to add link labels, as you require.

Ian Hopkinson
I use the Perl module for this, and it's extremely helpful.
Kev
+1  A: 

One of the big problems in displaying networks like this is figuring out where to put the nodes on the display screen. If arranging nodes is logically simple given your network, then an off-the-shelf product is likely to suit your needs.

If the arrangements are much more complicated, you may have to accept a certain amount of manual intervention to get this to work with off-the-shelf stuff, or byte the bullet and program the whole thing yourself.

.NET is one choice, and once you've mastered the Graphics class it's easy to use and plenty fast for something like this. However, there are probably better languages/platforms than .NET for something graphics-oriented like this.

Update: .NET is much better for 2D graphics than I knew. The key is finding a fast workaround to the pitifully slow GetPixel() and SetPixel() methods in the Bitmap class. Once you can read and write individual pixels easily and quickly, you can do whatever you want as a programmer.

MusiGenesis