/** * {@inheritDoc} */ public override GraphPath <V, E> getPath(V source, V sink) { if (!graph.containsVertex(source)) { throw new ArgumentException(GRAPH_MUST_CONTAIN_THE_SOURCE_VERTEX); } if (!graph.containsVertex(sink)) { throw new ArgumentException(GRAPH_MUST_CONTAIN_THE_SINK_VERTEX); } if (source.Equals(sink)) { return(createEmptyPath(source, sink)); } DijkstraClosestFirstIterator <V, E> it = new DijkstraClosestFirstIterator <V, E>(graph, source, radius); while (it.hasNext()) { V vertex = it.next(); if (vertex.Equals(sink)) { break; } } return(it.getPaths().getPath(sink)); }
/** * {@inheritDoc} * * Note that in the case of Dijkstra's algorithm it is more efficient to compute all * single-source shortest paths using this method than repeatedly invoking * {@link #getPath(Object, Object)} for the same source but different sink vertex. */ public override SingleSourcePaths <V, E> getPaths(V source) { if (!graph.containsVertex(source)) { throw new ArgumentException(GRAPH_MUST_CONTAIN_THE_SOURCE_VERTEX); } DijkstraClosestFirstIterator <V, E> it = new DijkstraClosestFirstIterator <V, E>(graph, source, radius); while (it.hasNext()) { it.next(); } return(it.getPaths()); }