Hi!
I've to display a graph like a tree level in hierarchy so I use the TreeLayout included in Jung (it's a general tree). I have based my code in MinimumSpanningTreeDemo.java, and works fine for simple cases, but when are more complex like the picture, I obtain something like the right side instead of something like the left side (which I intended to).
The layout that I used it as follows:
Graph<String,String> graph,graphcopy;
Forest<String,String> tree;
Layout<String,String> layout;
AbstractLayout layout2;
MinimumSpanningForest2<String,String> prim =
new MinimumSpanningForest2<String,String>(graph,
new DelegateForest<String,String>(), DelegateTree.<String,String>getFactory(),
new ConstantTransformer(1.0));
tree = prim.getForest();
collapser = new GraphCollapser(graph);
layout = new TreeLayout<String,String>(tree,100,100);
layout2 = new StaticLayout<String,String>(graph, layout);
Thanks in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
They'll get answered there more quickly and reliably.
The short version is that you need to hack (or subclass) TreeLayout so that it puts the root at the bottom rather than the top; this should be a pretty straightforward mathematical transformation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have already posted in http://stackoverflow.com/questions/39523190/rendering-in-jung like a month ago. My problem is that this is a directed graph that I want to display like a tree, but when there are two or more roots, the result is not that I expected.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
![](http://i.stack.imgur.com/vi8eO.png)
I've to display a graph like a tree level in hierarchy so I use the TreeLayout included in Jung (it's a general tree). I have based my code in MinimumSpanningTreeDemo.java, and works fine for simple cases, but when are more complex like the picture, I obtain something like the right side instead of something like the left side (which I intended to).
The layout that I used it as follows:
Thanks in advance!
Please post questions about JUNG to Stack Overflow: http://stackoverflow.com/questions/tagged/jung
They'll get answered there more quickly and reliably.
The short version is that you need to hack (or subclass) TreeLayout so that it puts the root at the bottom rather than the top; this should be a pretty straightforward mathematical transformation.
I have already posted in http://stackoverflow.com/questions/39523190/rendering-in-jung like a month ago. My problem is that this is a directed graph that I want to display like a tree, but when there are two or more roots, the result is not that I expected.
Thanks!
Sorry, I thought I'd already answered that question on StackOverflow.
Added a request for clarification on StackOverflow; let's take the conversation there.