Package com.jgalgo.alg
Interface ShortestPathAllPairs.Result<V,E>
-
- Type Parameters:
V
- the vertices typeE
- the edges type
- All Known Subinterfaces:
ShortestPathAllPairs.IResult
- Enclosing interface:
- ShortestPathAllPairs
public static interface ShortestPathAllPairs.Result<V,E>
A result object for anShortestPathAllPairs
algorithm.- Author:
- Barak Ugav
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description double
distance(V source, V target)
Get the distance of the shortest path between two vertices.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 source, V target)
Get the shortest path between vertices.
-
-
-
Method Detail
-
distance
double distance(V source, V 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<V,E> getPath(V source, V 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<V,E> getNegativeCycle()
Get the negative cycle that was found.- Returns:
- the negative cycle that was found.
- Throws:
IllegalArgumentException
- if a negative cycle was found. SeefoundNegativeCycle()
-
-