Menu

General Tree in JUNG

Tamara
2016-10-19
2016-11-06
  • Tamara

    Tamara - 2016-10-19

    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!

     
  • Joshua O'Madadhain

    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.

     
  • Tamara

    Tamara - 2016-11-06

    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!

     
  • Joshua O'Madadhain

    Sorry, I thought I'd already answered that question on StackOverflow.

    Added a request for clarification on StackOverflow; let's take the conversation there.

     

Log in to post a comment.