@Override public synchronized void clearMaxThroughput() { if (mtp != null) { mtp.reset(); // reset max throughput path } }
@Override public synchronized void clear() { DijkstraShortestPath<Node, Edge> spt; for (Short bw : this.sptBWAware.keySet()) { spt = this.sptBWAware.get(bw); if (spt != null) { spt.reset(); } } clearMaxThroughput(); }
/** * Returns the last edge on a shortest path from <code>source</code> to <code>target</code>, or * null if <code>target</code> is not reachable from <code>source</code>. * * <p>If either node is not in the graph for which this instance was created, throws <code> * IllegalArgumentException</code>. * * @param source the node where the shortest path starts * @param target the node where the shortest path ends * @return the last edge on a shortest path from {@code source} to {@code target} or null if * {@code target} is not reachable from {@code source} */ public E getIncomingEdge(N source, N target) { Preconditions.checkArgument( g.nodes().contains(target), "Specified target node %s is not part of graph %s", target, g); Preconditions.checkArgument( g.nodes().contains(source), "Specified source node %s is not part of graph %s", source, g); Set<N> targets = new HashSet<N>(); targets.add(target); singleSourceShortestPath(source, targets, g.nodes().size()); @SuppressWarnings("unchecked") Map<N, E> incomingEdgeMap = ((SourcePathData) sourceMap.get(source)).incomingEdges; E incomingEdge = incomingEdgeMap.get(target); if (!cached) { reset(source); } return incomingEdge; }
reset(source);
/** * <p>Returns the last edge on a shortest path from <code>source</code> * to <code>target</code>, or null if <code>target</code> is not * reachable from <code>source</code>.</p> * * <p>If either vertex is not in the graph for which this instance * was created, throws <code>IllegalArgumentException</code>.</p> */ public E getIncomingEdge(V source, V target) { if (!g.containsVertex(source)) throw new IllegalArgumentException("Specified source vertex " + source + " is not part of graph " + g); if (!g.containsVertex(target)) throw new IllegalArgumentException("Specified target vertex " + target + " is not part of graph " + g); Set<V> targets = new HashSet<V>(); targets.add(target); singleSourceShortestPath(source, targets, g.getVertexCount()); Map<V,E> incomingEdgeMap = ((SourcePathData)sourceMap.get(source)).incomingEdges; E incomingEdge = incomingEdgeMap.get(target); if (!cached) reset(source); return incomingEdge; }
reset(source);
/** * Returns a <code>LinkedHashMap</code> which maps each of the closest <code>numDests</code> nodes * to the <code>source</code> node in the graph (including the <code>source</code> node) to the * incoming edge along the path from that node. Throws an <code> * IllegalArgumentException</code> if <code>source</code> is not in this instance's graph, or if * <code>numDests</code> is either less than 1 or greater than the number of nodes in the graph. * * @see #getIncomingEdgeMap(Object) * @see #getPath(Object,Object) * @param source the node from which distances are measured * @param numDests the number of nodes for which to measure distances * @return a map from each of the closest {@code numDests} nodes to the last edge on the shortest * path to that node starting from {@code source} */ public LinkedHashMap<N, E> getIncomingEdgeMap(N source, int numDests) { Preconditions.checkArgument( g.nodes().contains(source), "Specified source node %s is not part of graph %s", source, g); Preconditions.checkArgument( numDests >= 1 && numDests <= g.nodes().size(), "number of destinations must be in [1, %d]", g.nodes().size()); singleSourceShortestPath(source, null, numDests); @SuppressWarnings("unchecked") LinkedHashMap<N, E> incomingEdgeMap = ((SourcePathData) sourceMap.get(source)).incomingEdges; if (!cached) { reset(source); } return incomingEdgeMap; }
reset(source);
/** * Invoked when the packet routing table of the VTN Manager has been * updated. * * @param notification A {@link RoutingUpdated} instance. */ @Override public void onRoutingUpdated(RoutingUpdated notification) { LOG.trace("onRoutingUpdated: {}", notification); if (notification == null) { return; } synchronized (this) { // Removed links needs to be processed before added links because // changed links are represented by a pair of removed and added // links. boolean updated = removeLinks(notification.getRemovedLink()); if (addLinks(notification.getAddedLink())) { updated = true; } if (updated) { resolver.reset(); notifyAll(); } } } }
spt.reset(); if (bw.equals(baseBW)) { clearMaxThroughput();