Package com.jgalgo.alg.shortestpath
Class KShortestPathsStAbstract
java.lang.Object
com.jgalgo.alg.shortestpath.KShortestPathsStAbstract
- All Implemented Interfaces:
KShortestPathsSt
- Direct Known Subclasses:
KShortestPathsStBasedPathsTree
Abstract class for computing the k-shortest paths in graphs.
The class implements the interface by solving the problem on the index graph and then maps the results back to the original graph. The implementation for index graphs is abstract and left to the subclasses.
- Author:
- Barak Ugav
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncomputeKShortestPaths
(Graph<V, E> g, WeightFunction<E> w, V source, V target, int k) Compute the K shortest paths from a source vertex to a target vertex.
-
Constructor Details
-
KShortestPathsStAbstract
public KShortestPathsStAbstract()Default constructor.
-
-
Method Details
-
computeKShortestPaths
public <V,E> List<Path<V,E>> computeKShortestPaths(Graph<V, E> g, WeightFunction<E> w, V source, V target, int k) Description copied from interface:KShortestPathsSt
Compute the K shortest paths from a source vertex to a target vertex.If
g
isIntGraph
, the returned object is a list ofIPath
. Ifg
isIntGraph
, prefer to passIWeightFunction
for best performance.- Specified by:
computeKShortestPaths
in interfaceKShortestPathsSt
- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- the graphw
- an edge weight functionsource
- the source vertextarget
- the target vertexk
- the number of shortest paths to compute- Returns:
k
shortest paths from the source to the target, or less if there are no suchk
paths
-