Package org.jgrapht.alg.shortestpath
Class DefaultManyToManyShortestPaths<V,E>
- java.lang.Object
- 
- org.jgrapht.alg.shortestpath.DefaultManyToManyShortestPaths<V,E>
 
- 
- Type Parameters:
- V- the graph vertex type
- E- the graph edge type
 - All Implemented Interfaces:
- ManyToManyShortestPathsAlgorithm<V,E>,- ShortestPathAlgorithm<V,E>
 
 public class DefaultManyToManyShortestPaths<V,E> extends Object Naive algorithm for many-to-many shortest paths problem using.For every pair of source and target vertices computes a shortest path between them and caches the result. For each pair of sourceandtargetvertex aShortestPathAlgorithmis used to compute the path. There is a way to provide the preferable implementation of the interface via thefunction.- Author:
- Semen Chudakov
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.ManyToManyShortestPathsAlgorithmManyToManyShortestPathsAlgorithm.BaseManyToManyShortestPathsImpl<V,E>, ManyToManyShortestPathsAlgorithm.ManyToManyShortestPaths<V,E>
 - 
Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.ShortestPathAlgorithmShortestPathAlgorithm.SingleSourcePaths<V,E>
 
- 
 - 
Constructor SummaryConstructors Constructor Description DefaultManyToManyShortestPaths(Graph<V,E> graph)Constructs a new instance of the algorithm for a givengraph.DefaultManyToManyShortestPaths(Graph<V,E> graph, Function<Graph<V,E>,ShortestPathAlgorithm<V,E>> function)Constructs a new instance of the algorithm for a givengraphandfunction.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ManyToManyShortestPathsAlgorithm.ManyToManyShortestPaths<V,E>getManyToManyPaths(Set<V> sources, Set<V> targets)Computes shortest paths from all vertices insourcesto all vertices intargets.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.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.
 
- 
- 
- 
Field Detail- 
graphprotected final Graph<V,E> graph 
 
- 
 - 
Constructor Detail- 
DefaultManyToManyShortestPathspublic DefaultManyToManyShortestPaths(Graph<V,E> graph) Constructs a new instance of the algorithm for a givengraph. Thefunctionis defaulted to returningBidirectionalDijkstraShortestPath.- Parameters:
- graph- a graph
 
 - 
DefaultManyToManyShortestPathspublic DefaultManyToManyShortestPaths(Graph<V,E> graph, Function<Graph<V,E>,ShortestPathAlgorithm<V,E>> function) Constructs a new instance of the algorithm for a givengraphandfunction.- Parameters:
- graph- a graph
- function- provides implementation of- ShortestPathAlgorithm
 
 
- 
 - 
Method Detail- 
getManyToManyPathspublic ManyToManyShortestPathsAlgorithm.ManyToManyShortestPaths<V,E> getManyToManyPaths(Set<V> sources, Set<V> targets) Description copied from interface:ManyToManyShortestPathsAlgorithmComputes shortest paths from all vertices insourcesto all vertices intargets.- Parameters:
- sources- list of sources vertices
- targets- list of target vertices
- Returns:
- computed shortest paths
 
 - 
getPathpublic GraphPath<V,E> getPath(V source, V sink) Get a shortest path from a source vertex to a sink vertex.- Specified by:
- getPathin interface- ShortestPathAlgorithm<V,E>
- Parameters:
- source- the source vertex
- sink- the target vertex
- Returns:
- a shortest path or null if no path exists
 
 - 
getPathWeightpublic double getPathWeight(V source, V sink)Get the weight of the shortest path from a source vertex to a sink vertex. ReturnsDouble.POSITIVE_INFINITYif no path exists.- Specified by:
- getPathWeightin interface- ShortestPathAlgorithm<V,E>
- Parameters:
- source- the source vertex
- sink- 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
 
 - 
getPathspublic ShortestPathAlgorithm.SingleSourcePaths<V,E> getPaths(V source) Compute all shortest paths starting from a single source vertex.- Specified by:
- getPathsin interface- ShortestPathAlgorithm<V,E>
- Parameters:
- source- the source vertex
- Returns:
- the shortest paths
 
 - 
getShortestPathsTreeprotected 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 type
- E- the graph edge type
- Parameters:
- graph- a graph
- source- source vertex
- targets- target vertices
- Returns:
- shortest paths starting from sourceand reaching alltargets
 
 
- 
 
-