/** * Returns a {@code Map} from each element {@code t} of {@code targets} to the shortest-path * distance from {@code source} to {@code t}. * * @param source the node from which the distance to each target is to be measured * @param targets the nodes to which the distance from the source is to be measured * @return {@code Map} from each element of {@code targets} to its distance from {@code source} */ public Map<N, Number> getDistanceMap(N source, Collection<N> targets) { Preconditions.checkArgument( g.nodes().contains(source), "Specified source node %s is not part of graph %s", source, g); Preconditions.checkArgument( targets.size() <= maxTargets, "size of target set %d exceeds maximum number of targets allowed: %d", targets.size(), this.maxTargets); Map<N, Number> distanceMap = singleSourceShortestPath(source, targets, Math.min(g.nodes().size(), maxTargets)); if (!cached) { reset(source); } return distanceMap; }
/** * Returns a {@code Map} from each element {@code t} of {@code targets} to the * shortest-path distance from {@code source} to {@code t}. * @param source the vertex from which the distance to each target is to be measured * @param targets the vertices to which the distance from the source is to be measured * @return {@code Map} from each element of {@code targets} to its distance from {@code source} */ public Map<V,Number> getDistanceMap(V source, Collection<V> targets) { if (g.containsVertex(source) == false) throw new IllegalArgumentException("Specified source vertex " + source + " is not part of graph " + g); if (targets.size() > max_targets) throw new IllegalArgumentException("size of target set exceeds maximum " + "number of targets allowed: " + this.max_targets); Map<V,Number> distanceMap = singleSourceShortestPath(source, targets, Math.min(g.getVertexCount(), max_targets)); if (!cached) reset(source); return distanceMap; }
/** * Returns a {@code Map} from each element {@code t} of {@code targets} to the * shortest-path distance from {@code source} to {@code t}. */ public Map<V,Number> getDistanceMap(V source, Collection<V> targets) { if (g.containsVertex(source) == false) throw new IllegalArgumentException("Specified source vertex " + source + " is not part of graph " + g); if (targets.size() > max_targets) throw new IllegalArgumentException("size of target set exceeds maximum " + "number of targets allowed: " + this.max_targets); Map<V,Number> distanceMap = singleSourceShortestPath(source, targets, Math.min(g.getVertexCount(), max_targets)); if (!cached) reset(source); return distanceMap; }
/** * Returns a {@code Map} from each element {@code t} of {@code targets} to * the shortest-path distance from {@code source} to {@code t}. */ public Map<V, Number> getDistanceMap(V source, Collection<V> targets) { if (g.containsVertex(source) == false) { throw new IllegalArgumentException("Specified source vertex " + source + " is not part of graph " + g); } if (targets.size() > max_targets) { throw new IllegalArgumentException( "size of target set exceeds maximum " + "number of targets allowed: " + this.max_targets); } Map<V, Number> distanceMap = singleSourceShortestPath(source, targets, Math.min(g.getVertexCount(), max_targets)); if (!cached) { reset(source); } return distanceMap; }
reset(source);
reset(source);