Hello,
First of all I want to thank you for all the work you put into JUNG.
My problem is that the nodes of my visual representation are very distributed, resulting in many line crossings and a unnecesairy complexity of the resulting image.
i use Jung for the layouting of the Graph, but draw the nodes and edges myself. Here is the code:
Graph<NetVisNode, NetVisEdge> g = new DirectedSparseMultigraph<NetVisNode, NetVisEdge>();
{then there are some nodes and edges attached. f.E:
NetVisNode node = new NetVisNode(chart, nodeText, region);
NetVisEdge newEdge = new NetVisEdge(chart, region, isDirected_, startNode, endNode,
(float) (adjacencyMatrix[yItr][xItr][OUTGOING_X]));
Transformer<NetVisEdge, Float> edgeTransformer =
new Transformer<NetVisEdge, Float>(){
public Float transform(NetVisEdge link) {
return 1/link.getWeight();
}
};
DijkstraDistance<NetVisNode, NetVisEdge> dDistance = new DijkstraDistance<NetVisNode, NetVisEdge>(g,edgeTransformer);
KKLayout<NetVisNode, NetVisEdge> layout = new KKLayout<NetVisNode, NetVisEdge>(
g,dDistance);
// sets the initial size of the space
layout.setSize(new Dimension(availableWidth_, availableHeight_));
layout.initialize();
// load x and y from jung layout for all nodes:
for (NetVisNode cvomNode : layout.getGraph().getVertices()) {
cvomNode.setY(layout.transform(cvomNode).getY() + getMargin()
+ 20);
cvomNode.setX(layout.transform(cvomNode).getX() + getMargin());
}
The weights are values between 0 and 1. Still I always get very long edges. My initial thought was that there is a problem with missing edges, resulting in a random positioning of the nodes. But looking into the graph (and layout) object, all nodes and edges are available
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
huh, accidentially submitted while editing sourcecode. Sorry for the bad formatting.
In the resulting graph (I take the coordinates from JUNG) the layout is not really optimal. Do I need to use more iteration steps or do i need to switch to SpringLayout? Is there another obvious mistake i've made?
thanks in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You need to advance the layout. Normally the visualization code takes care of this, but since you're doing your own rendering you can manually do this with the step() function (and then check to see whether the vertices have stabilized).
Joshua
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
First of all I want to thank you for all the work you put into JUNG.
My problem is that the nodes of my visual representation are very distributed, resulting in many line crossings and a unnecesairy complexity of the resulting image.
i use Jung for the layouting of the Graph, but draw the nodes and edges myself. Here is the code:
The weights are values between 0 and 1. Still I always get very long edges. My initial thought was that there is a problem with missing edges, resulting in a random positioning of the nodes. But looking into the graph (and layout) object, all nodes and edges are available
huh, accidentially submitted while editing sourcecode. Sorry for the bad formatting.
In the resulting graph (I take the coordinates from JUNG) the layout is not really optimal. Do I need to use more iteration steps or do i need to switch to SpringLayout? Is there another obvious mistake i've made?
thanks in advance!
You need to advance the layout. Normally the visualization code takes care of this, but since you're doing your own rendering you can manually do this with the step() function (and then check to see whether the vertices have stabilized).
Joshua