Interface KShortestPathsST
-
public interface KShortestPathsSTAn algorithm for computing the K shortest paths between two vertices in a graph.Given a graph \(G=(V,E)\), and a weight function \(w:E \rightarrow R\), one might ask what are the K shortest paths from a source vertex to a target vertex, where the 'shortest' is defined by comparing the sum of edges weights of each path. This interface computes such paths. It differ from
ShortestPathST, as it computes multiple paths, and not just one.Use
newInstance()to get a default implementation of this interface. A builder obtained vianewBuilder()may support different options to obtain different implementations.- Author:
- Barak Ugav
- See Also:
ShortestPathST,ShortestPathSingleSource
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceKShortestPathsST.BuilderA builder forKShortestPathsSTobjects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
List<Path<V,E>>computeKShortestPaths(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.static KShortestPathsST.BuildernewBuilder()Create a new K shortest paths algorithm builder.static KShortestPathsSTnewInstance()Create a new K shortest paths algorithm object.
-
-
-
Method Detail
-
computeKShortestPaths
<V,E> List<Path<V,E>> computeKShortestPaths(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.If
gisIntGraph, the returned object is a list ofIPath. IfgisIntGraph, prefer to passIWeightFunctionfor best performance.- 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:
kshortest paths from the source to the target, or less if there are no suchkpaths
-
newInstance
static KShortestPathsST newInstance()
Create a new K shortest paths algorithm object.This is the recommended way to instantiate a new
KShortestPathsSTobject. TheKShortestPathsST.Buildermight support different options to obtain different implementations.- Returns:
- a default implementation of
KShortestPathsST
-
newBuilder
static KShortestPathsST.Builder newBuilder()
Create a new K shortest paths algorithm builder.Use
newInstance()for a default implementation.- Returns:
- a new builder that can build
KShortestPathsSTobjects
-
-