Package org.graph4j.shortestpath
Interface SinglePairShortestPath
- All Known Implementing Classes:
AStarAlgorithm,BFSSinglePairShortestPath,BidirectionalDijkstra
public interface SinglePairShortestPath
Contract for single-pair shortest path algorithms, that is finding a shortest
path from s to t, for given vertices s and t.
- Author:
- Cristian Frăsinaru
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfindPath()Returns the shortest path between source and target.getGraph()Returns the input graph on which the algorithm is executed.static SinglePairShortestPathgetInstance(Graph graph, int source, int target) Returns the default implementation of this interface.default doubleReturns the weight of the shortest path from the source to the target, orDouble.POSITIVE_INFINITYif no path exists.intReturns the source vertex number.intReturns the target vertex number.
-
Method Details
-
getGraph
Graph getGraph()Returns the input graph on which the algorithm is executed.- Returns:
- the input graph.
-
findPath
Path findPath()Returns the shortest path between source and target.- Returns:
- the shortest path from the source to the target, or null if no path exists
-
getSource
int getSource()Returns the source vertex number.- Returns:
- the source vertex number.
-
getTarget
int getTarget()Returns the target vertex number.- Returns:
- the target vertex number.
-
getPathWeight
default double getPathWeight()Returns the weight of the shortest path from the source to the target, orDouble.POSITIVE_INFINITYif no path exists.- Returns:
- the weight of the shortest path from the source to the target, or
Double.POSITIVE_INFINITYif no path exists.
-
getInstance
Returns the default implementation of this interface.- Parameters:
graph- the input graph.source- the source vertex.target- the target vertex.- Returns:
- the default implementation of this interface.
-