MulticastTree extends NetworkElement { public void setLinks (Set<Link> newLinkSet) { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); SortedMap<Node,List<Link>> newPathToEgressNodeOfReachedNodes = netPlan.checkMulticastTreeValidityForDemand (newLinkSet , demand).getFirst(); final double currentCarriedTrafficIfAllOk = carriedTrafficIfNotFailing; final double currentOccupiedCapacityIfAllOk = occupiedLinkCapacityIfNotFailing; setCarriedTraffic(0, 0); layer.cache_multicastTreesDown.remove(this); layer.cache_multicastTreesTravLinkZeroCap.remove(this); for (Link e : this.linkSet) e.cache_traversingTrees.remove (this); for (Node node : this.cache_traversedNodes) node.cache_nodeAssociatedulticastTrees.remove (this); this.linkSet = new TreeSet<> (newLinkSet); this.pathToReachableEgressNode = newPathToEgressNodeOfReachedNodes; Triple<SortedSet<Node>,SortedMap<Node,Link>,SortedMap<Node,SortedSet<Link>>> caches = updateCaches (demand.ingressNode , this.pathToReachableEgressNode , this.linkSet); this.cache_traversedNodes = caches.getFirst (); this.cache_ingressLinkOfNode = caches.getSecond (); this.cache_egressLinksOfNode = caches.getThird (); boolean treeIsUp = demand.ingressNode.isUp; boolean treeIsTravZeroCapLink = false; for (Link e : newLinkSet) { e.cache_traversingTrees.add (this); treeIsUp = (treeIsUp && e.isUp && e.destinationNode.isUp); if (e.capacity < Configuration.precisionFactor) treeIsTravZeroCapLink = true; } for (Node node : cache_traversedNodes) { treeIsUp = treeIsUp && node.isUp; node.cache_nodeAssociatedulticastTrees.add (this); } if (!treeIsUp) layer.cache_multicastTreesDown.add (this); if (treeIsTravZeroCapLink) layer.cache_multicastTreesTravLinkZeroCap.add(this); setCarriedTraffic(currentCarriedTrafficIfAllOk, currentOccupiedCapacityIfAllOk); if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); } MulticastTree(NetPlan netPlan , long id , int index,  MulticastDemand demand , Set<Link> links , AttributeMap attributes); Set<Link> getInitialLinkSet(); void revertToInitialSetOfLinks(); boolean isUpTheInitialLinkSet(); NetworkLayer getLayer(); Set<SharedRiskGroup> getSRGs(); MulticastDemand getMulticastDemand(); Node getIngressNode(); Set<Node> getEgressNodesReached(); boolean isReachedEgressNode(Node n); boolean isReachinAllDemandEgressNodes(); List<Link> getSeqLinksToEgressNode(Node egressNode); void setLinks(Set<Link> newLinkSet); Set<Link> getLinkSet(); boolean isDown(); boolean isTraversingZeroCapLinks(); Set<Node> getNodeSet(); Link getIngressLinkOfNode(Node n); Set<Link> getOutputLinkOfNode(Node n); double getTreeTotalLengthInKm(); double getTreeMaximumPathLengthInKm(); double getTreeAveragePathLengthInKm(); double getTreeMaximumPropagationDelayInMs(); double getTreeAveragePropagationDelayInMs(); int getTreeMaximumPathLengthInHops(); double getTreeAveragePathLengthInHops(); int getTreeNumberOfLinks(); double getCarriedTraffic(); double getOccupiedLinkCapacity(); double getCarriedTrafficInNoFailureState(); double getOccupiedLinkCapacityInNoFailureState(); void setCarriedTraffic(double newCarriedTraffic , double newOccupiedLinkCapacity); void remove(); @Override String toString();  }
@Test public void testSetLinks() { t123.setLinks(star); assertEquals(t123.getLinkSet() , star); assertEquals(t123.getInitialLinkSet() , line123); }