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
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:
The plateau method is a bit illustrated here.
If it is possible for you to read German then this lecture is nice:
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.
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.
There has been a similar request before, but looking for all paths on StackOverflow. Find all paths in a graph with DFS
Hope this helps, it was answered but not with the exact solution, but more of a guide