2

I would like to visualise a graph (which is not a tree) in JUNG, using the tree layout. I understand that that may seem a bit odd, but the thing is the following. The application is backed by a Neo4J database. There are a bunch of nodes in them, all connected via several types of relationships. In other words, I have a cyclic graph.

If I imaginatively remove all the relationships except the ones with relationship type *IS_PARENT*, what I have left is a perfect tree. So there is a tree structure in my data, which JUNG can't see because of the other relations that make it cyclic.

There are 2 main reasons why I want to be doing this.

  1. Readability. There's a logic structure in my data, and I would very much like to visualise it.
  2. I have reason to believe that this will increase the performance of my application. At the moment the performance is very poor, due to the large amount of vertices & edges. I have also looked into another visualisation tool called Prefuse, and there I discovered that tree layout is a lot easier to deal with, at least that was the case in Prefuse and I'm hoping the same will be true for JUNG.

So there's a lot of benefit in it for me. I'm hoping someone here might be able to help me because I wasn't able to find something.

Pieter-Jan
  • 1,675
  • 2
  • 19
  • 25
  • there are already tutorials out there how to use JUNG with neo4j. http://maxdemarzi.com/2012/03/13/jung-in-neo4j-part-1/ http://maxdemarzi.com/2012/03/16/jung-in-neo4j-part-2/ . somewhere in the getData section i saw a place where you can define an exact relationship type - in your case the one which should get you a tree – ulkas Nov 16 '12 at 15:26
  • My apologies, I might have not made myself entirely clear. My application already works. I just want to change the JUNG Layout from FRLayout (which appears to be a rather difficult calculation) to TreeLayout, which should be a lot easier to draw. Unfortunately, I've "enriched" my tree with other relations that make it cyclic, and so JUNG doesn't accept it as a tree. I want JUNG to draw those other relations, but I don't want them taken into consideration as far as Layout is concerned. – Pieter-Jan Nov 19 '12 at 07:50

1 Answers1

2

I found the solution. I decompiled the TreeLayout class, and simply changed the way it calculates the amount of children, and now it works like a charm. Only when using predicates, it remembers the old positions, and not the new ones...

Pieter-Jan
  • 1,675
  • 2
  • 19
  • 25
  • Thanks so much for answering your own question, rather that just letting this rot. I did the same thing and it works like a charm! – nook Aug 07 '13 at 04:00