Displaying Tree from Java (BlueJ)

I implemented a tree in Java (using BlueJ IDE) and I need to get a graphical representation of this tree. How can this be done? Is there some kind of tutorial? And if I export the data of the tree to a text file will I need a specific format so that Graphviz can read it?

A general tutorial can be

A general tutorial can be found at http://www.graphviz.org/pdf/dotguide.pdf. Additional information can be found at http://www.graphviz.org/Documentation.php.

Graphviz only reads input in the DOT language. It is simple and easy to generate. For example, a simple binary tree might look like

digraph {
0 -> 1
0 -> 2
1 -> 3
1 -> 4
2 -> 5
2 -> 6
}

or

digraph {
0 -> {1 2}
1 -> {3 4}
2 -> {5 6}
}

 

This gives the basic graph topology. You can attach a wide assortment of attributes to node and edges to tailor the image.

Recent comments