Module org.jgrapht.core
Package org.jgrapht.alg.shortestpath
Class BaseManyToManyShortestPaths<V,E>
- 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 java.lang.Object implements ManyToManyShortestPathsAlgorithm<V,E>
Base class for many-to-many shortest paths algorithms. Currently extended byCHManyToManyShortestPaths
andDijkstraManyToManyShortestPaths
.
-
-
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>
-
-
Constructor Summary
Constructors Constructor Description BaseManyToManyShortestPaths(Graph<V,E> graph)
Constructs a new instance of the algorithm for a given graph.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphPath<V,E>
getPath(V source, V sink)
Get a shortest path from a source vertex to a sink 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.protected static <V,E>
ShortestPathAlgorithm.SingleSourcePaths<V,E>getShortestPathsTree(Graph<V,E> graph, V source, java.util.Set<V> targets)
Computes shortest paths tree starting atsource
and stopping as soon as all of thetargets
are reached.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.alg.interfaces.ManyToManyShortestPathsAlgorithm
getManyToManyPaths
-
-
-
-
Method Detail
-
getPath
public GraphPath<V,E> getPath(V source, V sink)
Get a shortest path from a source vertex to a sink vertex.- Specified by:
getPath
in interfaceShortestPathAlgorithm<V,E>
- Parameters:
source
- the source vertexsink
- the target vertex- Returns:
- a shortest path or null if no path exists
-
getPathWeight
public double getPathWeight(V source, V sink)
Get the weight of the shortest path from a source vertex to a sink vertex. ReturnsDouble.POSITIVE_INFINITY
if no path exists.- Specified by:
getPathWeight
in 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_INFINITY
if no path exists
-
getPaths
public ShortestPathAlgorithm.SingleSourcePaths<V,E> getPaths(V source)
Compute all shortest paths starting from a single source vertex.- Specified by:
getPaths
in 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, java.util.Set<V> targets)
Computes shortest paths tree starting atsource
and stopping as soon as all of thetargets
are reached. Here theDijkstraClosestFirstIterator
is 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
source
and reaching alltargets
-
-