Package com.jgalgo.alg.shortestpath
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.Path<V,E>
getPath(V source, V target)
Get the shortest path between vertices.boolean
isReachable(V source, V target)
Check if a target vertex is reachable from a source vertex.Set<V>
reachableVerticesFrom(V source)
Get the set of vertices that are reachable from a source vertex.Set<V>
reachableVerticesTo(V target)
Get the set of vertices that can reach a target vertex.
-
-
-
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:
NoSuchVertexException
- ifsource
ortarget
are not vertices in the graphIllegalArgumentException
- if the shortest paths were computed on pairs of vertices from a subset of the vertices of the graph (rather than all pairs), andsource
ortarget
are not in the subset
-
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:
NoSuchVertexException
- ifsource
ortarget
are not vertices in the graphIllegalArgumentException
- if the shortest paths were computed on pairs of vertices from a subset of the vertices of the graph (rather than all pairs), andsource
ortarget
are not in the subset
-
isReachable
boolean isReachable(V source, V target)
Check if a target vertex is reachable from a source vertex.A vertex is reachable from itself.
- Parameters:
source
- the source vertextarget
- the target vertex- Returns:
true
if there is a path from the source to the target,false
otherwise- Throws:
NoSuchVertexException
- ifsource
ortarget
are not vertices in the graph
-
reachableVerticesFrom
Set<V> reachableVerticesFrom(V source)
Get the set of vertices that are reachable from a source vertex.A vertex is reachable from itself.
If the result was obtained from a calculation on a subset of the vertices of the graph, this method may throw an exception, return only the vertices in the subset, or return all vertices reachable.
- Parameters:
source
- the source vertex- Returns:
- the set of vertices that are reachable from the source vertex
- Throws:
NoSuchVertexException
- ifsource
is not a vertex in the graph
-
reachableVerticesTo
Set<V> reachableVerticesTo(V target)
Get the set of vertices that can reach a target vertex.A vertex can reach itself.
If the result was obtained from a calculation on a subset of the vertices of the graph, this method may throw an exception, return only the vertices in the subset, or return all vertices reachable.
- Parameters:
target
- the target vertex- Returns:
- the set of vertices that can reach the target vertex
- Throws:
NoSuchVertexException
- iftarget
is not a vertex in the graph
-
-