Module org.jgrapht.core
Package org.jgrapht.alg.shortestpath
Class DijkstraManyToManyShortestPaths.DijkstraManyToManyShortestPathsImpl
- java.lang.Object
-
- org.jgrapht.alg.interfaces.ManyToManyShortestPathsAlgorithm.BaseManyToManyShortestPathsImpl<V,E>
-
- org.jgrapht.alg.shortestpath.DijkstraManyToManyShortestPaths.DijkstraManyToManyShortestPathsImpl
-
- All Implemented Interfaces:
ManyToManyShortestPathsAlgorithm.ManyToManyShortestPaths<V,E>
- Enclosing class:
- DijkstraManyToManyShortestPaths<V,E>
private class DijkstraManyToManyShortestPaths.DijkstraManyToManyShortestPathsImpl extends ManyToManyShortestPathsAlgorithm.BaseManyToManyShortestPathsImpl<V,E>
Implementation of theManyToManyShortestPathsAlgorithm.ManyToManyShortestPaths
. For each source vertex a single source shortest paths tree is stored. It is used to retrieve both actual paths and theirs weights.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
reversed
Indicates is the search spaces were computed on the edge reversed graph.private java.util.Map<V,ShortestPathAlgorithm.SingleSourcePaths<V,E>>
searchSpaces
Map from source vertices to corresponding single source shortest path trees.
-
Constructor Summary
Constructors Constructor Description DijkstraManyToManyShortestPathsImpl(java.util.Set<V> sources, java.util.Set<V> targets, boolean reversed, java.util.Map<V,ShortestPathAlgorithm.SingleSourcePaths<V,E>> searchSpaces)
Constructs an instance of the algorithm for the givensources
,targets
,reversed
andsearchSpaces
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphPath<V,E>
getPath(V source, V target)
Return the path from thesource
vertex to thetarget
vertex.double
getWeight(V source, V target)
Return the weight of the path from thesource
vertex to thetarget
vertex orDouble.POSITIVE_INFINITY
if there is no such path in the graph.-
Methods inherited from class org.jgrapht.alg.interfaces.ManyToManyShortestPathsAlgorithm.BaseManyToManyShortestPathsImpl
assertCorrectSourceAndTarget, getSources, getTargets
-
-
-
-
Field Detail
-
reversed
private boolean reversed
Indicates is the search spaces were computed on the edge reversed graph.
-
searchSpaces
private final java.util.Map<V,ShortestPathAlgorithm.SingleSourcePaths<V,E>> searchSpaces
Map from source vertices to corresponding single source shortest path trees.
-
-
Constructor Detail
-
DijkstraManyToManyShortestPathsImpl
DijkstraManyToManyShortestPathsImpl(java.util.Set<V> sources, java.util.Set<V> targets, boolean reversed, java.util.Map<V,ShortestPathAlgorithm.SingleSourcePaths<V,E>> searchSpaces)
Constructs an instance of the algorithm for the givensources
,targets
,reversed
andsearchSpaces
.- Parameters:
sources
- source verticestargets
- target verticesreversed
- if search spaces are reversedsearchSpaces
- single source shortest paths trees map
-
-
Method Detail
-
getPath
public GraphPath<V,E> getPath(V source, V target)
Return the path from thesource
vertex to thetarget
vertex. If no such path exists, null is returned.- Parameters:
source
- source vertextarget
- target vertex- Returns:
- path between
source
andtarget
or null if no such path exists
-
getWeight
public double getWeight(V source, V target)
Return the weight of the path from thesource
vertex to thetarget
vertex orDouble.POSITIVE_INFINITY
if there is no such path in the graph. The weight of the path between a vertex and itself is always zero.- Parameters:
source
- source vertextarget
- target vertex- Returns:
- the weight of the path between source and sink vertices or
Double.POSITIVE_INFINITY
in case no such path exists
-
-