Package com.jgalgo
Interface ShortestPathAllPairs.Result
-
- Enclosing interface:
- ShortestPathAllPairs
public static interface ShortestPathAllPairs.ResultA result object for anShortestPathAllPairsalgorithm.- Author:
- Barak Ugav
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description doubledistance(int source, int target)Get the distance of the shortest path between two vertices.booleanfoundNegativeCycle()Check whether a negative cycle was found.PathgetNegativeCycle()Get the negative cycle that was found.PathgetPath(int source, int target)Get the shortest path between vertices.
-
-
-
Method Detail
-
distance
double distance(int source, int target)Get the distance of the shortest path between two vertices.- Parameters:
source- the source vertextarget- the target vertex- Returns:
- the sum of weights of edges in the shortest path from the source to target,
or
Double.POSITIVE_INFINITYif no such path exists - Throws:
IllegalArgumentException- if a negative cycle found. SeefoundNegativeCycle()
-
getPath
Path getPath(int source, int target)
Get the shortest path between vertices.- Parameters:
source- the source vertextarget- the target vertex- Returns:
- the shortest path from the source to target, or
nullif no such path exists - Throws:
IllegalArgumentException- if a negative cycle found. SeefoundNegativeCycle()
-
foundNegativeCycle
boolean foundNegativeCycle()
Check whether a negative cycle was found.If a negative cycle was found, there is no unique shortest paths, as the paths weight could be arbitrary small by going through the cycle multiple times.
- Returns:
trueif a negative cycle was found
-
getNegativeCycle
Path getNegativeCycle()
Get the negative cycle that was found.- Returns:
- the negative cycle that was found.
- Throws:
IllegalArgumentException- if a negative cycle was found. SeefoundNegativeCycle()
-
-