Georgii Dernovyi
Georgii Dernovyi

Reputation: 49

jung2: how to draw a graph as a tree?

I need to draw my graph that has a root node and childs have crossrelations between them as standard graphviz draw algorithm. Root on the top, childs below. Treelayout and RadialTreeLayout do not suit (not strong tree and show buggy view for my tree when it's tree). Is there a way to draw a graph as graphviz without Forest and TreeLayout, RadialTreeLayout? I can't find standard layout for SparseMultigraph that does that.

Upvotes: 1

Views: 183

Answers (1)

Joshua O'Madadhain
Joshua O'Madadhain

Reputation: 2704

The basic idea is that you extract a tree from your original graph, lay out that tree using TreeLayout, and then use the positions from that layout as the input to a StaticLayout for the original graph.

There's sample code that does that here: https://github.com/jrtom/jung/blob/master/jung-samples/src/main/java/edu/uci/ics/jung/samples/MinimumSpanningTreeDemo.java

Upvotes: 1

Related Questions