java.lang.Object
org.jgrapht.alg.shortestpath.BaseManyToManyShortestPaths<V,E>
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
ManyToManyShortestPathsAlgorithm<V,,E> ShortestPathAlgorithm<V,E>
- Direct Known Subclasses:
CHManyToManyShortestPaths,DefaultManyToManyShortestPaths,DijkstraManyToManyShortestPaths
abstract class BaseManyToManyShortestPaths<V,E>
extends Object
implements ManyToManyShortestPathsAlgorithm<V,E>
Base class for many-to-many shortest paths algorithms. Currently extended by
CHManyToManyShortestPaths and DijkstraManyToManyShortestPaths.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.ManyToManyShortestPathsAlgorithm
ManyToManyShortestPathsAlgorithm.BaseManyToManyShortestPathsImpl<V,E>, ManyToManyShortestPathsAlgorithm.ManyToManyShortestPaths<V, E> Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.ShortestPathAlgorithm
ShortestPathAlgorithm.SingleSourcePaths<V,E> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBaseManyToManyShortestPaths(Graph<V, E> graph) Constructs a new instance of the algorithm for a given graph. -
Method Summary
Modifier and TypeMethodDescriptionGet a shortest path from a source vertex to a sink vertex.Compute all shortest paths starting from a single source vertex.doublegetPathWeight(V source, V sink) Get the weight of the shortest path from a source vertex to a sink vertex.protected static <V,E> ShortestPathAlgorithm.SingleSourcePaths <V, E> getShortestPathsTree(Graph<V, E> graph, V source, Set<V> targets) Computes shortest paths tree starting atsourceand stopping as soon as all of thetargetsare reached.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jgrapht.alg.interfaces.ManyToManyShortestPathsAlgorithm
getManyToManyPaths
-
Field Details
-
graph
-
-
Constructor Details
-
BaseManyToManyShortestPaths
Constructs a new instance of the algorithm for a given graph.- Parameters:
graph- the graph
-
-
Method Details
-
getPath
Get a shortest path from a source vertex to a sink vertex.- Specified by:
getPathin interfaceShortestPathAlgorithm<V,E> - Parameters:
source- the source vertexsink- the target vertex- Returns:
- a shortest path or null if no path exists
-
getPathWeight
Get the weight of the shortest path from a source vertex to a sink vertex. ReturnsDouble.POSITIVE_INFINITYif no path exists.- Specified by:
getPathWeightin interfaceShortestPathAlgorithm<V,E> - Parameters:
source- the source vertexsink- the sink vertex- Returns:
- the weight of the shortest path from a source vertex to a sink vertex, or
Double.POSITIVE_INFINITYif no path exists
-
getPaths
Compute all shortest paths starting from a single source vertex.- Specified by:
getPathsin interfaceShortestPathAlgorithm<V,E> - Parameters:
source- the source vertex- Returns:
- the shortest paths
-
getShortestPathsTree
protected static <V,E> ShortestPathAlgorithm.SingleSourcePaths<V,E> getShortestPathsTree(Graph<V, E> graph, V source, Set<V> targets) Computes shortest paths tree starting atsourceand stopping as soon as all of thetargetsare reached. Here theDijkstraClosestFirstIteratoris used.- Type Parameters:
V- the graph vertex typeE- the graph edge type- Parameters:
graph- a graphsource- source vertextargets- target vertices- Returns:
- shortest paths starting from
sourceand reaching alltargets
-