Using JDK 1.7+Jung2.
I have a similarity matrix and want to analyze it graphically using jung2 graphs. My dataset is composed by data like:
object1 object2 0.54454
object1 object3 0.45634
object2 object3 0.90023
[..]
For each line, the value represents the similarity between the previous objects (i.e.: object1 has 0.54454 similarity with object2)
I want to create a graph where the distance between vertices is proportional to their edge value. For the example above, the object1 would be placed closer to object2 than to object3, because sim(object1,object2) > sim(object2,object3).
How can I achieve such task using Jung2? Default layouts dont seem to do this.
This depends on the layout that you intend to use. For the
SpringLayout, you can pass aTransformerto the constructor as thelength_functionparameter, that you can simply implement asYou'll always have to take into account that - depending on the structure of the graph - it might simply not be possible to lay out the vertices as desired. For example, if the similarities do not obey the http://en.wikipedia.org/wiki/Triangle_inequality , then there is no suitable embedding of these similarities into the 2D space.