[jgrapht-users] Shortest path from a source
Brought to you by:
barak_naveh,
perfecthash
From: Adib R. <adi...@gm...> - 2017-11-27 03:12:29
|
Hello, I created a graph using jGrapht library which is based on a network topology and printed the results as follows: of:0000000000000191:3,of:0000000000000003:1 of:0000000000000191:2,of:0000000000000002:1 of:0000000000000192:3,of:0000000000000003:2 of:0000000000000192:2,of:0000000000000002:2 of:0000000000000191:1,of:0000000000000001:1 of:0000000000000192:1,of:0000000000000001:2 of:0000000000000003:1,of:0000000000000191:3 of:0000000000000003:2,of:0000000000000192:3 of:0000000000000002:1,of:0000000000000191:2 of:0000000000000001:1,of:0000000000000191:1 of:0000000000000002:2,of:0000000000000192:2 of:0000000000000001:2,of:0000000000000192:1 Each vertex in my graph is defined as a device ID and a port number. I tried to run a shortest path algorithm to find the shortest path between two end points as follows: DijkstraShortestPath<TopoVertex, TopoEdge> dijkstraAlg = new DijkstraShortestPath<>(topoStore.getDirectedGraph()); TopoVertex src = new TopoVertex("of:0000000000000001", "2"); TopoVertex dst = new TopoVertex("of:0000000000000002", "2"); ShortestPathAlgorithm.SingleSourcePaths<TopoVertex, TopoEdge> iPaths = dijkstraAlg.getPaths(src); System.out.println(iPaths.getPath(dst) + "\n"); It prints null but there is a path between these two end points. Any suggestions? Thanks, Adib |