V
- vertices typeE
- edges typepublic abstract class BaseBidirectionalShortestPathAlgorithm<V,E> extends Object
BidirectionalDijkstraShortestPath
and BidirectionalAStarShortestPath
.ShortestPathAlgorithm.SingleSourcePaths<V,E>
Modifier and Type | Field and Description |
---|---|
protected Graph<V,E> |
graph
The underlying graph.
|
protected static String |
GRAPH_CONTAINS_A_NEGATIVE_WEIGHT_CYCLE
Error message for reporting the existence of a negative-weight cycle.
|
protected static String |
GRAPH_MUST_CONTAIN_THE_SINK_VERTEX
Error message for reporting that a sink vertex is missing.
|
protected static String |
GRAPH_MUST_CONTAIN_THE_SOURCE_VERTEX
Error message for reporting that a source vertex is missing.
|
Constructor and Description |
---|
BaseBidirectionalShortestPathAlgorithm(Graph<V,E> graph)
Constructs a new instance of the algorithm for a given graph.
|
Modifier and Type | Method and Description |
---|---|
protected GraphPath<V,E> |
createEmptyPath(V source,
V sink)
Create an empty path.
|
protected GraphPath<V,E> |
createPath(org.jgrapht.alg.shortestpath.BaseBidirectionalShortestPathAlgorithm.BaseSearchFrontier forwardFrontier,
org.jgrapht.alg.shortestpath.BaseBidirectionalShortestPathAlgorithm.BaseSearchFrontier backwardFrontier,
double weight,
V source,
V commonVertex,
V sink)
Builds shortest path between
source and sink based on the information
provided by search frontiers and common vertex. |
ShortestPathAlgorithm.SingleSourcePaths<V,E> |
getPaths(V source)
Compute all shortest paths starting from a single source vertex.
|
double |
getPathWeight(V source,
V sink)
Get the weight of the shortest path from a source vertex to a sink vertex.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPath
protected static final String GRAPH_CONTAINS_A_NEGATIVE_WEIGHT_CYCLE
protected static final String GRAPH_MUST_CONTAIN_THE_SOURCE_VERTEX
protected static final String GRAPH_MUST_CONTAIN_THE_SINK_VERTEX
protected final Graph<V,E> graph
protected GraphPath<V,E> createPath(org.jgrapht.alg.shortestpath.BaseBidirectionalShortestPathAlgorithm.BaseSearchFrontier forwardFrontier, org.jgrapht.alg.shortestpath.BaseBidirectionalShortestPathAlgorithm.BaseSearchFrontier backwardFrontier, double weight, V source, V commonVertex, V sink)
source
and sink
based on the information
provided by search frontiers and common vertex.forwardFrontier
- forward direction frontierbackwardFrontier
- backward direction frontierweight
- weight of the shortest pathsource
- path sourcecommonVertex
- path common vertexsink
- path sinkpublic ShortestPathAlgorithm.SingleSourcePaths<V,E> getPaths(V source)
getPaths
in interface ShortestPathAlgorithm<V,E>
source
- the source vertexpublic double getPathWeight(V source, V sink)
Double.POSITIVE_INFINITY
if no path exists.getPathWeight
in interface ShortestPathAlgorithm<V,E>
source
- the source vertexsink
- the sink vertexDouble.POSITIVE_INFINITY
if no path existsprotected final GraphPath<V,E> createEmptyPath(V source, V sink)
source
- the source vertexsink
- the sink vertexCopyright © 2019. All rights reserved.