/** * Compare two subtrees to see if they match (taking into account the renameableNames * and the restrictedNames). */ public bool matches(SafraTreeNode this_node, SafraTreeNode other_node) { Debug.Assert(this_node != null && other_node != null); if (this_node == null || other_node == null) { return(false); } if (!renameableNames().get(this_node.getID())) { // this is not a new node, so we require a perfect match.. if (other_node.getID() != this_node.getID()) { return(false); } } else { // we are flexible with the id, as long as the id wasn't removed // in the tree if (restrictedNames().get(other_node.getID())) { return(false); } } Debug.Assert(this_node.getLabeling() == other_node.getLabeling()); Debug.Assert(this_node.hasFinalFlag() == other_node.hasFinalFlag()); // this node looks good, now the children SafraTreeNode this_child = this_node.getOldestChild(); SafraTreeNode other_child = other_node.getOldestChild(); while (this_child != null && other_child != null) { if (!matches(this_child, other_child)) { return(false); } this_child = this_child.getYoungerBrother(); other_child = other_child.getYoungerBrother(); } Debug.Assert(this_child == null && other_child == null); return(true); }
/** * Generate the appropriate acceptance signature for Rabin Acceptance for this tree */ public override void generateAcceptance(AcceptanceForState acceptance) { for (int i = 0; i < getNodeMax(); i++) { SafraTreeNode stn = this[i]; if (stn == null) { acceptance.addTo_U(i); } else { if (stn.hasFinalFlag()) { acceptance.addTo_L(i); } } } }
public override void generateAcceptance(RabinSignature acceptance) { acceptance.setSize(getNodeMax()); for (int i = 0; i < getNodeMax(); i++) { SafraTreeNode stn = this[i]; if (stn == null) { acceptance.setColor(i, RabinColor.RABIN_RED); } else { if (stn.hasFinalFlag()) { acceptance.setColor(i, RabinColor.RABIN_GREEN); } else { acceptance.setColor(i, RabinColor.RABIN_WHITE); } } } }