Package com.jgalgo
Interface ShortestPathAllPairs.Result
-
- Enclosing interface:
- ShortestPathAllPairs
public static interface ShortestPathAllPairs.Result
A result object for anShortestPathAllPairs
algorithm.- Author:
- Barak Ugav
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description double
distance(int source, int target)
Get the distance of the shortest path between two vertices.boolean
foundNegativeCycle()
Check whether a negative cycle was found.Path
getNegativeCycle()
Get the negative cycle that was found.Path
getPath(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_INFINITY
if 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
null
if 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:
true
if 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()
-
-