V
- the graph vertex typeE
- the graph edge typepublic final class BidirectionalDijkstraShortestPath<V,E> extends Object
See the Wikipedia article for details and references about bidirectional search. This technique does not change the worst-case behavior of the algorithm but reduces, in some cases, the number of visited vertices in practice. This implementation alternatively constructs forward and reverse paths from the source and target vertices respectively.
DijkstraShortestPath
Constructor and Description |
---|
BidirectionalDijkstraShortestPath(Graph<V,E> graph,
V startVertex,
V endVertex)
Creates the instance and executes the bidirectional Dijkstra shortest path algorithm.
|
BidirectionalDijkstraShortestPath(Graph<V,E> graph,
V startVertex,
V endVertex,
double radius)
Creates the instance and executes the bidirectional Dijkstra shortest path algorithm.
|
Modifier and Type | Method and Description |
---|---|
static <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.
|
GraphPath<V,E> |
getPath()
Return the path found.
|
List<E> |
getPathEdgeList()
Return the edges making up the path.
|
double |
getPathLength()
Return the weighted length of the path found.
|
public BidirectionalDijkstraShortestPath(Graph<V,E> graph, V startVertex, V endVertex)
graph
- the input graphstartVertex
- the vertex at which the path should startendVertex
- the vertex at which the path should endpublic BidirectionalDijkstraShortestPath(Graph<V,E> graph, V startVertex, V endVertex, double radius)
graph
- the input graphstartVertex
- the vertex at which the path should startendVertex
- the vertex at which the path should endradius
- limit on weighted path length, or Double.POSITIVE_INFINITY for unbounded searchpublic List<E> getPathEdgeList()
public GraphPath<V,E> getPath()
public double getPathLength()
public static <V,E> List<E> findPathBetween(Graph<V,E> graph, V startVertex, V endVertex)
V
- the graph vertex typeE
- the graph edge typegraph
- the graph to be searchedstartVertex
- the vertex at which the path should startendVertex
- the vertex at which the path should endCopyright © 2016. All rights reserved.