Package org.jgrapht.alg
Class DijkstraShortestPath<V,E>
java.lang.Object
org.jgrapht.alg.DijkstraShortestPath<V,E>
An implementation of Dijkstra's
shortest path algorithm using
ClosestFirstIterator
.- Since:
- Sep 2, 2003
- Author:
- John V. Sichi
-
Constructor Summary
ConstructorsConstructorDescriptionCreates and executes a new DijkstraShortestPath algorithm instance.Creates and executes a new DijkstraShortestPath algorithm instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic <V,
E> List <E> findPathBetween
(Graph<V, E> graph, V startVertex, V endVertex) Convenience method to find the shortest path via a single static method call.getPath()
Return the path found.Return the edges making up the path found.double
Return the length of the path found.
-
Constructor Details
-
DijkstraShortestPath
Creates and executes a new DijkstraShortestPath algorithm instance. An instance is only good for a single search; after construction, it can be accessed to retrieve information about the path found.- Parameters:
graph
- the graph to be searchedstartVertex
- the vertex at which the path should startendVertex
- the vertex at which the path should end
-
DijkstraShortestPath
Creates and executes a new DijkstraShortestPath algorithm instance. An instance is only good for a single search; after construction, it can be accessed to retrieve information about the path found.- Parameters:
graph
- the graph to be searchedstartVertex
- the vertex at which the path should startendVertex
- the vertex at which the path should endradius
- limit on path length, or Double.POSITIVE_INFINITY for unbounded search
-
-
Method Details
-
getPathEdgeList
Return the edges making up the path found.- Returns:
- List of Edges, or null if no path exists
-
getPath
Return the path found.- Returns:
- path representation, or null if no path exists
-
getPathLength
public double getPathLength()Return the length of the path found.- Returns:
- path length, or Double.POSITIVE_INFINITY if no path exists
-
findPathBetween
Convenience method to find the shortest path via a single static method call. If you need a more advanced search (e.g. limited by radius, or computation of the path length), use the constructor instead.- Parameters:
graph
- the graph to be searchedstartVertex
- the vertex at which the path should startendVertex
- the vertex at which the path should end- Returns:
- List of Edges, or null if no path exists
-