Class ShortestPathAllPairsAbstract
- All Implemented Interfaces:
ShortestPathAllPairs
- Direct Known Subclasses:
ShortestPathAllPairsCardinality,ShortestPathAllPairsFloydWarshall,ShortestPathAllPairsJohnson
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.jgalgo.alg.shortestpath.ShortestPathAllPairs
ShortestPathAllPairs.Builder, ShortestPathAllPairs.IResult, ShortestPathAllPairs.Result<V,E> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<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.
-
Constructor Details
-
ShortestPathAllPairsAbstract
public ShortestPathAllPairsAbstract()Default constructor.
-
-
Method Details
-
computeAllShortestPaths
public <V,E> ShortestPathAllPairs.Result<V,E> computeAllShortestPaths(Graph<V, E> g, WeightFunction<E> w) Description copied from interface:ShortestPathAllPairsCompute 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.- Specified by:
computeAllShortestPathsin interfaceShortestPathAllPairs- 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
public <V,E> ShortestPathAllPairs.Result<V,E> computeSubsetShortestPaths(Graph<V, E> g, Collection<V> verticesSubset, WeightFunction<E> w) Description copied from interface:ShortestPathAllPairsCompute 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.- Specified by:
computeSubsetShortestPathsin interfaceShortestPathAllPairs- 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
-