Visualizing trees in java with JUNG

Posted on October 11, 2009. Filed under: Uncategorized | Tags: , , , , |

I was looking for a way to visualize a tree (of probabilities) in java. I came across JUNG (on sourceforge). There is a nice example (java applet) which displays a tree and lets the user collapse the subtrees on any node, exactly what I was looking for ! (I found out later that one can even drag the nodes of the tree around with the mouse)

I downloaded the binary release (, this seems to contain a bunch of jar files however it looks there is no source code of the above mentioned example. From the source of the example page, I could figure out the class name. After having found out which module I had to checkout from CVS (jung2), I could find the source code for the tree collapsing example, see this link (at least that’s what I think it is) in the CVS browser. I added the necessary (binary) jar files and I got the tree collapsing demo to run.

Another interesting example demonstrating different layout algorithms is showlayouts and the corresponding source code in CVS seems to be here.

There is also a nice step-by-step tutorial (with code snippets) by Greg Bernstein (linked from JUNG’s documentation page) which shows how to create graphs in section 2 and has a visualization demo in section 4. Thanks to the bookmarks in the PDF (which are not opened by default), navigation in the whole tutorial is very easy. Within minutes, one can put together a simple example of a graph with three vertices and two edges and display it on the screen.


Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: