Interface ShortestPathSingleSource.IResult
-
- All Superinterfaces:
ShortestPathSingleSource.Result<Integer,Integer>
- Enclosing interface:
- ShortestPathSingleSource
public static interface ShortestPathSingleSource.IResult extends ShortestPathSingleSource.Result<Integer,Integer>
A result object for theShortestPathSingleSourceproblem forIntGraph.- Author:
- Barak Ugav
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description intbacktrackEdge(int target)Get the last edge on the shortest path from the source to the given target.default IntegerbacktrackEdge(Integer target)Deprecated.Please usebacktrackEdge(int)instead to avoid un/boxing.doubledistance(int target)Get the distance to a target vertex.default doubledistance(Integer target)Deprecated.Please usedistance(int)instead to avoid un/boxing.IPathgetPath(int target)Get shortest path to a target vertex.default IPathgetPath(Integer target)Deprecated.Please usegetPath(int)instead to avoid un/boxing.IntGraphgraph()Get the graph on which the shortest paths were computed on.default IntGraphshortestPathTree()Get the shortest path tree.default IntGraphshortestPathTree(boolean directed)Get the shortest path tree, optionally directed or undirected.default Integersource()Deprecated.Please usesourceInt()instead to avoid un/boxing.intsourceInt()Get the source vertex from which all shortest paths were computed from.
-
-
-
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:
NoSuchVertexException- iftargetis not a vertex in the graph
-
distance
@Deprecated default double distance(Integer target)
Deprecated.Please usedistance(int)instead to avoid un/boxing.Get the distance to a target vertex.- Specified by:
distancein interfaceShortestPathSingleSource.Result<Integer,Integer>- 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
-
getPath
IPath 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:
NoSuchVertexException- iftargetis not a vertex in the graph
-
getPath
@Deprecated default IPath getPath(Integer target)
Deprecated.Please usegetPath(int)instead to avoid un/boxing.Get shortest path to a target vertex.- Specified by:
getPathin interfaceShortestPathSingleSource.Result<Integer,Integer>- Parameters:
target- a target vertex in the graph- Returns:
- the shortest path from the source to the target or
nullif no such path found.
-
backtrackEdge
int backtrackEdge(int target)
Get the last edge on the shortest path from the source to the given target.The backtrack edge is an in-edge of the given target vertex. The set of all backtrack edges of all vertices define the shortest path tree of the source, and each shortest path can be constructed from them.
- Parameters:
target- a target vertex in the graph- Returns:
- the backtrack edge, the last edge on the shortest path from the source to th given target, or
-1if there is no path to the target or the target is the source
-
backtrackEdge
@Deprecated default Integer backtrackEdge(Integer target)
Deprecated.Please usebacktrackEdge(int)instead to avoid un/boxing.Get the last edge on the shortest path from the source to the given target.The backtrack edge is an in-edge of the given target vertex. The set of all backtrack edges of all vertices define the shortest path tree of the source, and each shortest path can be constructed from them.
- Specified by:
backtrackEdgein interfaceShortestPathSingleSource.Result<Integer,Integer>- Parameters:
target- a target vertex in the graph- Returns:
- the backtrack edge, the last edge on the shortest path from the source to th given target, or
nullif there is no path to the target or the target is the source
-
shortestPathTree
default IntGraph shortestPathTree()
Description copied from interface:ShortestPathSingleSource.ResultGet the shortest path tree.The shortest path tree is constructed from the vertices and edges used by any shortest path. It contains only the vertices reachable from the source, and for each vertex other than the source the graph will contains the edge that was used to reach it (see
ShortestPathSingleSource.Result.backtrackEdge(Object)). If there are \(k\) reachable vertices, the graph will contain \(k-1\) edges.The returned graph will be directed if the original graph is directed. In such case, the tree is directed from the source to the other vertices. To control the directionality of the returned graph, use
ShortestPathSingleSource.Result.shortestPathTree(boolean).- Specified by:
shortestPathTreein interfaceShortestPathSingleSource.Result<Integer,Integer>- Returns:
- undirected shortest path tree
-
shortestPathTree
default IntGraph shortestPathTree(boolean directed)
Description copied from interface:ShortestPathSingleSource.ResultGet the shortest path tree, optionally directed or undirected.The shortest path tree is constructed from the vertices and edges used by any shortest path. It contains only the vertices reachable from the source, and for each vertex other than the source the graph will contains the edge that was used to reach it (see
ShortestPathSingleSource.Result.backtrackEdge(Object)). If there are \(k\) reachable vertices, the graph will contain \(k-1\) edges.- Specified by:
shortestPathTreein interfaceShortestPathSingleSource.Result<Integer,Integer>- Parameters:
directed- iftruethe returned tree will be directed. If the original graph was undirected and a directed tree is created, the edges in the tree will be directed from the source towards the other vertices- Returns:
- un/directed shortest path tree
-
sourceInt
int sourceInt()
Get the source vertex from which all shortest paths were computed from.- Returns:
- the source vertex
-
source
@Deprecated default Integer source()
Deprecated.Please usesourceInt()instead to avoid un/boxing.Get the source vertex from which all shortest paths were computed from.- Specified by:
sourcein interfaceShortestPathSingleSource.Result<Integer,Integer>- Returns:
- the source vertex
-
graph
IntGraph graph()
Description copied from interface:ShortestPathSingleSource.ResultGet the graph on which the shortest paths were computed on.- Specified by:
graphin interfaceShortestPathSingleSource.Result<Integer,Integer>- Returns:
- the graph on which the shortest paths were computed on.
-
-