Route extends NetworkElement { public void remove () { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); this.setCarriedTraffic(0, 0); if (bidirectionalPair != null) { this.bidirectionalPair.bidirectionalPair = null; this.bidirectionalPair = null; } for (Node node : cache_seqNodesRealPath) node.cache_nodeAssociatedRoutes.remove(this); for (Link link : cache_seqLinksRealPath) link.cache_traversingRoutes.remove(this); demand.cache_routes.remove(this); for (Route backupRoute : backupRoutes) backupRoute.cache_routesIAmBackUp.remove(this); for (Route primaryRoute : cache_routesIAmBackUp) primaryRoute.backupRoutes.remove(this); netPlan.cache_id2RouteMap.remove(id); layer.cache_routesDown.remove (this); layer.cache_routesTravLinkZeroCap.remove(this); NetPlan.removeNetworkElementAndShiftIndexes(layer.routes , index); for (NetworkElement e : cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.keySet()) if (e instanceof Resource) ((Resource) e).removeTraversingRoute(this); for (String tag : tags) netPlan.cache_taggedElements.get(tag).remove(this); if (cache_hasLoops) { demand.routingCycleType = RoutingCycleType.LOOPLESS; for (Route r : demand.cache_routes) if (r.cache_hasLoops) { demand.routingCycleType = RoutingCycleType.OPEN_CYCLES; break; } } if (demand.cache_worstCasePropagationTimeMs <= this.cache_propagationDelayMs) { demand.cache_worstCasePropagationTimeMs = 0; for (Route r : demand.cache_routes) demand.cache_worstCasePropagationTimeMs = Math.max(demand.cache_worstCasePropagationTimeMs, r.cache_propagationDelayMs); } if (demand.cache_worstCaseLengthInKm <= this.getLengthInKm()) { demand.cache_worstCaseLengthInKm = 0; for (Route r : demand.cache_routes) demand.cache_worstCaseLengthInKm = Math.max(demand.cache_worstCaseLengthInKm, r.getLengthInKm()); } final NetPlan npOld = this.netPlan; removeId(); if (ErrorHandling.isDebugEnabled()) npOld.checkCachesConsistency(); } Route(NetPlan netPlan , long id , int index , Demand demand , List<? extends NetworkElement> seqLinksAndResourcesTraversed , AttributeMap attributes); Route getBidirectionalPair(); void setBidirectionalPair(Route r); boolean isBidirectional(); Route createBidirectionalOppositePair(); boolean isServiceChain(); SortedSet<Route> getRoutesIAmBackup(); List<Route> getBackupRoutes(); Triple<Double,List<NetworkElement>,List<Double>> getInitialState(); List<NetworkElement> getPath(); List<NetworkElement> getOppositePath(); boolean isBackupRoute(); boolean hasBackupRoutes(); void addBackupRoute(Route backupRoute); void removeBackupRoute(Route backupRoute); double getCarriedTraffic(); double getOccupiedCapacity(NetworkElement ... e); double getCarriedTrafficInNoFailureState(); double getOccupiedCapacityInNoFailureState(NetworkElement ... e); Demand getDemand(); Node getEgressNode(); Node getFirstAvailableNodeAfterFailures(); Node getFirstAvailableNodeBeforeFailures(); Node getIngressNode(); NetworkLayer getLayer(); double getLengthInKm(); int getNumberOfHops(); double getPropagationDelayInMiliseconds(); double getPropagationSpeedInKmPerSecond(); List<Double> getSeqOccupiedCapacitiesIfNotFailing(); boolean isOccupyingDifferentCapacitiesInDifferentLinksInNoFailureState(); List<Resource> getSeqResourcesTraversed(); List<Link> getSeqLinks(); List<Node> getSeqNodes(); List<Node> getSeqIntermediateNodes(); int getNumberOfTimesIsTraversed(NetworkElement e); SortedSet<SharedRiskGroup> getSRGs(); boolean hasLoops(); boolean isDown(); boolean isTraversingZeroCapLinks(); void remove(); void setCarriedTraffic(double newCarriedTraffic , double newOccupiedLinkAndResourcesCapacities); void setCarriedTraffic(double newCarriedTraffic , List<Double> linkAndResourcesOccupationInformation); void setPath(double newCarriedTraffic , List<? extends NetworkElement> newPath , List<Double> newOccupationInformation); void setSeqLinks(List<Link> seqLinks); @Override String toString(); static List<Link> getSeqLinks(List<? extends NetworkElement> seqLinksAndResources); static List<Resource> getSeqResources(List<? extends NetworkElement> seqLinksAndResources);  }
@Test public void testRemove() { r123a.remove(); assertEquals (d13.getRoutes() , new HashSet<Route> (Arrays.asList(r123b , segm13))); assertEquals (scd123.getRoutes() , Collections.singleton(sc123)); sc123.remove(); assertEquals (scd123.getRoutes() , Collections.emptySet()); }