private void freeArcEmbedding(designGraph Lmapping, designGraph host, designGraph Rmapping) { /* There are nodes in host which may have been left dangling due to the fact that their * connected nodes were part of the L-R deletion. These now need to be either 1) connected * up to their new nodes, 2) their references to old nodes need to be changed to null if * intentionally left dangling, or 3) the arcs are to be removed. In the function * removeLdiffKfromHost we remove old nodes but leave their references intact on their * connected arcs. This allows us to quickly find the list of freeArcs that are candidates * for the embedding rules. Essentially, we are capturing the neighborhood within the host * for the rule application, that is the arcs that are affected by the deletion of the L-R * subgraph. Should one check non-dangling non-neighborhood arcs? No, this would seem to * cause a duplication of such an arc. Additionally, what node in host should the arc remain * attached to? There seems to be no rigor in applying these more global (non-neighborhood) * changes within the literature as well for the general edNCE method. */ sbyte freeEndIdentifier; node newNodeToConnect, nodeRemovedinLdiffRDeletion, toNode, fromNode; node neighborNode = null; int numOfArcs = host.arcs.Count; for (int i = 0; i != numOfArcs; i++) { /* first, check to see if the arc is really a freeArc that needs updating. */ if (embeddingRule.arcIsFree(host.arcs[i], host, out freeEndIdentifier, neighborNode)) { arc freeArc = host.arcs[i]; /* For each of the embedding rules, we see if it is applicable to the identified freeArc. * The rule then modifies the arc by simply pointing it to the new node in R as indicated * by the embedding Rule's RNodeName. NOTE: the order of the rules are important. If two * rules are 'recognized' with the same freeArc only the first one will modify it, as it * will then remove it from the freeArc list. This is useful in that rules may have precedence * to one another. There is an exception if the rule has allowArcDuplication set to true, * since this would simply create a copy of the arc. */ foreach (embeddingRule eRule in embeddingRules) { newNodeToConnect = eRule.findNewNodeToConnect(R, Rmapping); nodeRemovedinLdiffRDeletion = eRule.findDeletedNode(L, Lmapping); if (eRule.ruleIsRecognized(freeEndIdentifier, freeArc, neighborNode, nodeRemovedinLdiffRDeletion)) { #region set up new connection points if (freeEndIdentifier >= 0) { if (eRule.newDirection >= 0) { toNode = newNodeToConnect; fromNode = freeArc.From; } else { toNode = freeArc.From; fromNode = newNodeToConnect; } } else { if (eRule.newDirection <= 0) { fromNode = newNodeToConnect; toNode = freeArc.To; } else { fromNode = freeArc.To; toNode = newNodeToConnect; } } #endregion #region if making a copy of arc, duplicate it and all the characteristics if (eRule.allowArcDuplication) { /* under the allowArcDuplication section, we will be making a copy of the * freeArc. This seems a little error-prone at first, since if there is only * one rule that applies to freeArc then we will have good copy and the old * bad copy. However, at the end of this function, we go through the arcs again * and remove any arcs that still appear free. This also serves the purpose to * delete any dangling nodes that were not recognized in any rules. */ host.addArc(freeArc.copy(), fromNode, toNode); } #endregion #region else, just update the old freeArc else { freeArc.From = fromNode; freeArc.To = toNode; break; /* skip to the next arc */ /* this is done so that no more embedding rules will be checked with this freeArc.*/ } #endregion } } } } #region clean up (i.e. delete) any freeArcs that are still in host.arcs for (int i = host.arcs.Count - 1; i >= 0; i--) { /* this seems a little archaic to use this i-counter instead of foreach. * the issue is that since we are removing nodes from the list as we go * through it, we very well can't use foreach. The countdown allows us to * disregard problems with the deleting. */ if ((host.arcs[i].From != null && !host.nodes.Contains(host.arcs[i].From)) || (host.arcs[i].To != null && !host.nodes.Contains(host.arcs[i].To))) host.removeArc(host.arcs[i]); } #endregion }
private void removeLdiffKfromHost(designGraph Lmapping, designGraph host) { /* foreach node in L - see if it "is" also in R - if it is in R than it "is" part of the * commonality subgraph K, and thus should not be deleted as it is part of the connectivity * information for applying the rule. Note that what we mean by "is" is that there is a * node with the same name. The name tag in a node is not superficial - it contains * useful connectivity information. We use it as a stand in for referencing the same object * this is different than the local lables which are used for recognition and the storage * any important design information. */ for (int i = 0; i != L.nodes.Count; i++) { if (!R.nodes.Exists(delegate(node b) { return (b.name == L.nodes[i].name); })) { /* if a node with the same name does not exist in R, then it is safe to remove it. * The removeNode should is invoked with the "false false" switches of this function. * This causes the arcs to be unaffected by the deletion of a connecting node. Why * do this? It is important in the edNCE approach that is appended to the DPO approach * (see the function freeArcEmbedding) in connecting up a new R to the elements of L * a node was connected to. */ host.removeNode(Lmapping.nodes[i], false, false); } } for (int i = 0; i != L.arcs.Count; i++) { if (!R.arcs.Exists(delegate(arc b) { return (b.name == L.arcs[i].name); })) { /* the removal of arcs happens in a similar way. */ host.removeArc(Lmapping.arcs[i]); } } }