Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

k-shortest (alternative) path algorithm, java implementations

Could you recommend any java library which implements k-shortest algorithm -> searching for alternative ways, not the only shortest one in directed multigraph ?

I found only JGraphT but there is actually bug (which i submitted) but it will take a lot of time to fix it i guess, are there any other available implementations ? Except JGraphT i found only small one-man projects :/

OR would be hard to modify Disjktra shortest path alg to show alternative paths ?

Thanks

like image 337
Martin V. Avatar asked Oct 07 '12 22:10

Martin V.


2 Answers

2 Possible Options:

Option 1. The class KshortestPath from the MascOpt Package is a good option for a Java implementation of k-shortest paths.

Option 2. You can also try this from code.google.com This seems to be a one person's effort, but the good thing is that the algorithm is shared: Yen's Ranking - the details are here.(http://www.ohloh.net/p/k-shortest-paths)

Note: Finding the shortest-paths between all pairs of nodes in a given graph is a different problem. See this SO question on Dijkstra vs. Floyd-Warshall.

Also note that k-shortest paths for rich graphs tend to be slight variations of the (Dijkstra) shortest path - alternative paths between vertices on the shortest-path with slightly higher costs.

I know the OP asked for Java implementations but if people have a choice and R is an option, then the kBestShortestPaths package from CRAN is a very good option as well.

Hope that helps.

like image 179
Ram Narasimhan Avatar answered Nov 04 '22 02:11

Ram Narasimhan


Finding the k-shortest paths is related but not the exact same problem as alternative paths. Good alternative paths are more complicated. Have a read where other similar approaches are outlined:

  • k-Shortest Paths
  • Pareto optimality
  • Plateau method
  • Penalty approach

The plateau method is a bit illustrated here.

If it is possible for you to read German then this lecture is nice:

  • e.g. optimizing regarding time or distance => problem: interesting alternatives are missing
  • dijunct paths => same problem
  • k-shortest paths => problem: the real alternative is probably NOT under the first 1000 paths

Page 5

So intuition tells us: an alternative should have nearly identical distance or time. but should be significant different. so the first idea: find a path which minizes length AND similarity. Problem: there could be local detours.

Page 6

we introduce a 3rd criterion: local optimumality: every short subpath needs to be a shortest path.

like image 40
Karussell Avatar answered Nov 04 '22 03:11

Karussell