Package com.jgalgo
Interface ShortestPathSingleSource.Result
-
- Enclosing interface:
- ShortestPathSingleSource
public static interface ShortestPathSingleSource.ResultA result object for theShortestPathSingleSourceproblem.- Author:
- Barak Ugav
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description doubledistance(int target)Get the distance to a target vertex.booleanfoundNegativeCycle()Check whether a negative cycle was found.PathgetNegativeCycle()Get the negative cycle that was found.PathgetPath(int target)Get shortest path to a target vertex.
-
-
-
Method Detail
-
distance
double distance(int target)
Get the distance to a target vertex.- Parameters:
target- a target vertex in the graph- Returns:
- the sum of the shortest path edges from the source to the target, or
Double.POSITIVE_INFINITYif no such path found. - Throws:
IllegalStateException- if and negative cycle was found andfoundNegativeCycle()returntrue.
-
getPath
Path getPath(int target)
Get shortest path to a target vertex.- Parameters:
target- a target vertex in the graph- Returns:
- the shortest path from the source to the target or
nullif no such path found. - Throws:
IllegalStateException- if a negative cycle was found andfoundNegativeCycle()returntrue.
-
foundNegativeCycle
boolean foundNegativeCycle()
Check whether a negative cycle was found.If a negative cycle was found, the 'shortest paths' are not well defined, as a path can loop in the cycle and achieve arbitrary small 'length'.
- Returns:
trueif a negative cycle found, elsefalse.
-
getNegativeCycle
Path getNegativeCycle()
Get the negative cycle that was found.- Returns:
- the negative cycle that was found.
- Throws:
IllegalStateException- if no negative cycle was found andfoundNegativeCycle()returnfalse.
-
-