V - the graph vertex typeE - the graph edge typepublic class EppsteinKShortestPath<V,E> extends Object implements KShortestPathAlgorithm<V,E>
The algorithm is originally described in: David Eppstein. 1999. Finding the k Shortest Paths. SIAM J. Comput. 28, 2 (February 1999), 652-673. DOI=http://dx.doi.org/10.1137/S0097539795290477.
The main advantage ot this algorithm is that it achieves the complexity of $O(m + n\log n + k\log k)$ while guaranteeing that the paths are produced in sorted order by weight, where $m$ is the number of edges in the graph, $n$ is the number of vertices in the graph and $k$ is the number of paths needed.
This implementation can only be used for directed simple graphs.
EppsteinShortestPathIterator| Constructor and Description |
|---|
EppsteinKShortestPath(Graph<V,E> graph)
Constructs the algorithm instance for the given
graph. |
| Modifier and Type | Method and Description |
|---|---|
List<GraphPath<V,E>> |
getPaths(V source,
V sink,
int k)
Computes
k shortest paths between source and sink. |
public List<GraphPath<V,E>> getPaths(V source, V sink, int k)
k shortest paths between source and sink. If the number of
paths is denoted by $n$, the method returns $m = min\{k, n\}$ such paths. The paths are
produced in sorted order by weights.getPaths in interface KShortestPathAlgorithm<V,E>source - the source vertexsink - the target vertexk - the number of shortest paths to returnCopyright © 2019. All rights reserved.