Interface ShortestPathAllPairs
-
public interface ShortestPathAllPairsAn algorithm that compute all pairs shortest path (APSP) in a graph.The regular
ShortestPathSingleSourcecan be used \(n\) times to achieve the same result, but it may be more efficient to use a APSP algorithm in the first place.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceShortestPathAllPairs.BuilderA builder forShortestPathAllPairsobjects.static interfaceShortestPathAllPairs.IResultA result object for anShortestPathAllPairsalgorithm forIntGraph.static interfaceShortestPathAllPairs.Result<V,E>A result object for anShortestPathAllPairsalgorithm.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
ShortestPathAllPairs.Result<V,E>computeAllShortestPaths(Graph<V,E> g, WeightFunction<E> w)Compute the shortest path between each pair of vertices in a graph.<V,E>
ShortestPathAllPairs.Result<V,E>computeSubsetShortestPaths(Graph<V,E> g, Collection<V> verticesSubset, WeightFunction<E> w)Compute the shortest path between each pair of vertices in a given subset of the vertices of the graph.static ShortestPathAllPairs.BuildernewBuilder()Create a new all pairs shortest paths algorithm builder.static ShortestPathAllPairsnewInstance()Create a new all-pairs-shortest-paths algorithm object.
-
-
-
Method Detail
-
computeAllShortestPaths
<V,E> ShortestPathAllPairs.Result<V,E> computeAllShortestPaths(Graph<V,E> g, WeightFunction<E> w)
Compute the shortest path between each pair of vertices in a graph.Given an edge weight function, the length of a path is the weight sum of all edges of the path. The shortest path from a source vertex to some other vertex is the path with the minimum weight.
To compute the shortest cardinality (non weighted) paths, pass
nullinstead of the weight functionw.If
gis anIntGraph, aShortestPathAllPairs.IResultobject will be returned. In that case, its better to pass aIWeightFunctionaswto avoid boxing/unboxing.- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- a graphw- an edge weight function- Returns:
- a result object containing information on the shortest path between each pair of vertices
-
computeSubsetShortestPaths
<V,E> ShortestPathAllPairs.Result<V,E> computeSubsetShortestPaths(Graph<V,E> g, Collection<V> verticesSubset, WeightFunction<E> w)
Compute the shortest path between each pair of vertices in a given subset of the vertices of the graph.To compute the shortest cardinality (non weighted) paths, pass
nullinstead of the weight functionw.If
gis anIntGraph, aShortestPathAllPairs.IResultobject will be returned. In that case, its better to pass aIWeightFunctionaswandIntCollectionasverticesSubsetto avoid boxing/unboxing.- Type Parameters:
V- the vertices typeE- the edges type- Parameters:
g- a graphverticesSubset- a subset of vertices of the graph. All shortest paths will be computed between each pair of vertices from the subsetw- as edge weight function- Returns:
- a result object containing information on the shortest path between each pair of vertices in the subset
-
newInstance
static ShortestPathAllPairs newInstance()
Create a new all-pairs-shortest-paths algorithm object.This is the recommended way to instantiate a new
ShortestPathAllPairsobject. TheShortestPathAllPairs.Buildermight support different options to obtain different implementations.- Returns:
- a default implementation of
ShortestPathAllPairs
-
newBuilder
static ShortestPathAllPairs.Builder newBuilder()
Create a new all pairs shortest paths algorithm builder.Use
newInstance()for a default implementation.- Returns:
- a new builder that can build
ShortestPathAllPairsobjects
-
-