Package com.jgalgo.alg
Interface ShortestPathSingleSource.Result<V,E>
-
- Type Parameters:
V
- the vertices typeE
- the edges type
- All Known Subinterfaces:
ShortestPathSingleSource.IResult
- Enclosing interface:
- ShortestPathSingleSource
public static interface ShortestPathSingleSource.Result<V,E>
A result object for theShortestPathSingleSource
problem.- Author:
- Barak Ugav
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description double
distance(V target)
Get the distance to a target vertex.boolean
foundNegativeCycle()
Check whether a negative cycle was found.Path<V,E>
getNegativeCycle()
Get the negative cycle that was found.Path<V,E>
getPath(V target)
Get shortest path to a target vertex.
-
-
-
Method Detail
-
distance
double distance(V 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_INFINITY
if no such path found. - Throws:
IllegalStateException
- if and negative cycle was found andfoundNegativeCycle()
returntrue
.
-
getPath
Path<V,E> getPath(V 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
null
if 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:
true
if a negative cycle found, elsefalse
.
-
getNegativeCycle
Path<V,E> 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
.
-
-