k-shortest (alternative) path algorithm, java impl

2019-04-06 03:21发布

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

3条回答
地球回转人心会变
2楼-- · 2019-04-06 03:47

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.

查看更多
放我归山
3楼-- · 2019-04-06 03:50

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.

查看更多
该账号已被封号
4楼-- · 2019-04-06 03:51

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

查看更多
登录 后发表回答