I use the JUNG API to calculate shortest paths between several nodes in medium large graphs (20 to 100 nodes). Right now I'm iterating over my nodes and use the simple 'ShortetsPath' function to calculate the shortest path for two nodes. All the shortest paths are put in an ArrayList.
UnweightedShortestPath<Vertex, SEdge> dist = new UnweightedShortestPath<Vertex, SEdge>(undir);
ArrayList<Vertex> tv = new ArrayList<Vertex>(); // contains nodes for shortestpath
ArrayList<Integer> distances = new ArrayList<Integer>(); // for the distances
for (int j = 0; j <tv.size()-1;j++){ //iterate over nodes
Vertex one = tv.get(j);
for (int k = j+1; k<tv.size();k++){ //iterate over next nodes
Vertex two = tv.get(k);
Number n = dist.getDistance(one, two);
int d;
if (n == null) {
d = 5000000;
}
else {
d = n.intValue();
}
distances.add(d);
}
}
I would like to speed up the calculation because I have to calculate this for many graphs and nodes. As far as I know, only Dijkstra is available in the JUNG API. So my questions are: Can I use Dijkstra to boost performance? Are other algorithms available in the JUNG API? Would it make sense to use another graph implementation which offers more different methods for shortest paths?
Thanks so far :)