V - vertexW - weightpublic class Dijkstra<V,W extends java.lang.Number> extends java.lang.Object implements VisitDistance<V,W>
| Constructor and Description |
|---|
Dijkstra() |
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<V,java.util.List<Edge<V,W>>> |
getLastDistance()
Get the last calculated distance to all the possible destinations
The map contains all the possible vertices that are reachable from the source set in the visit If there is no path between the destination and the source, then null is returned as accordingly to the map interface If the visit is not already been done, then the map is null. |
V |
getLastSource()
Get the last source vertex of the visit for calculating the destinations.
Returns null if the visit is not already been done |
VisitInfo<V> |
visit(Graph<V,W> graph,
V source,
java.util.function.Consumer<V> visit)
With this the graph will be visited accordingly to the strategy of the visit.
Some strategy can accept a source vertex null, because they visit all the graph anyway. If you want to stop the visit of the graph, you just have to throw any exception in the visit function, but be sure to catch it |
public java.util.Map<V,java.util.List<Edge<V,W>>> getLastDistance()
VisitDistancegetLastDistance in interface VisitDistance<V,W extends java.lang.Number>public V getLastSource()
VisitDistancegetLastSource in interface VisitDistance<V,W extends java.lang.Number>public VisitInfo<V> visit(Graph<V,W> graph, V source, java.util.function.Consumer<V> visit) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
VisitStrategyvisit in interface VisitStrategy<V,W extends java.lang.Number>graph - the graph to visitsource - the source of the visitvisit - the function to apply at each vertex when they are visitedjava.lang.NullPointerException - if one of the arguments is null (only the consumers can be null)java.lang.IllegalArgumentException - if the source vertex is not in the graph