// The function front scans the frontier of nodePtr. It returns the keys // of the leaves found in the frontier of nodePtr in a SListPure. // These keys include keys of direction indicators detected in the frontier. // // No direction is assigned to the direction indicators. // void EmbedPQTree::getFront( PQNode<edge,IndInfo*,bool>* nodePtr, SListPure<PQBasicKey<edge,IndInfo*,bool>*> &keys) { ArrayBuffer<PQNode<edge,IndInfo*,bool>*> S; S.push(nodePtr); while (!S.empty()) { PQNode<edge,IndInfo*,bool> *checkNode = S.popRet(); if (checkNode->type() == PQNodeRoot::PQNodeType::Leaf) keys.pushBack((PQBasicKey<edge,IndInfo*,bool>*) checkNode->getKey()); else { PQNode<edge,IndInfo*,bool>* firstSon = nullptr; if (checkNode->type() == PQNodeRoot::PQNodeType::PNode) { firstSon = checkNode->referenceChild(); } else if (checkNode->type() == PQNodeRoot::PQNodeType::QNode) { firstSon = checkNode->getEndmost(PQNodeRoot::SibDirection::Right); // By this, we make sure that we start on the left side // since the left endmost child will be on top of the stack } if (firstSon->status() == PQNodeRoot::PQNodeStatus::Indicator) { keys.pushBack((PQBasicKey<edge,IndInfo*,bool>*) firstSon->getNodeInfo()); } else S.push(firstSon); PQNode<edge,IndInfo*,bool> *nextSon = firstSon->getNextSib(nullptr); PQNode<edge,IndInfo*,bool> *oldSib = firstSon; while (nextSon && nextSon != firstSon) { if (nextSon->status() == PQNodeRoot::PQNodeStatus::Indicator) keys.pushBack((PQBasicKey<edge,IndInfo*,bool>*) nextSon->getNodeInfo()); else S.push(nextSon); PQNode<edge,IndInfo*,bool> *holdSib = nextSon->getNextSib(oldSib); oldSib = nextSon; nextSon = holdSib; } } } }
// The function front scans the frontier of nodePtr. It returns the keys // of the leaves found in the frontier of nodePtr in a SListPure. // These keys include keys of direction indicators detected in the frontier. // // No direction is assigned to the direction indicators. // void EmbedPQTree::getFront( PQNode<edge,indInfo*,bool>* nodePtr, SListPure<PQBasicKey<edge,indInfo*,bool>*> &keys) { Stack<PQNode<edge,indInfo*,bool>*> S; S.push(nodePtr); while (!S.empty()) { PQNode<edge,indInfo*,bool> *checkNode = S.pop(); if (checkNode->type() == PQNodeRoot::leaf) keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) checkNode->getKey()); else { PQNode<edge,indInfo*,bool>* firstSon = 0; if (checkNode->type() == PQNodeRoot::PNode) { firstSon = checkNode->referenceChild(); } else if (checkNode->type() == PQNodeRoot::QNode) { firstSon = checkNode->getEndmost(RIGHT); // By this, we make sure that we start on the left side // since the left endmost child will be on top of the stack } if (firstSon->status() == INDICATOR) { keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) firstSon->getNodeInfo()); } else S.push(firstSon); PQNode<edge,indInfo*,bool> *nextSon = firstSon->getNextSib(0); PQNode<edge,indInfo*,bool> *oldSib = firstSon; while (nextSon && nextSon != firstSon) { if (nextSon->status() == INDICATOR) keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) nextSon->getNodeInfo()); else S.push(nextSon); PQNode<edge,indInfo*,bool> *holdSib = nextSon->getNextSib(oldSib); oldSib = nextSon; nextSon = holdSib; } } } }
// Overloads virtual function of base class PQTree // Allows ignoring the virtual direction indicators during // the template matching algorithm. PQNode<edge,indInfo*,bool>* EmbedPQTree::clientRightEndmost( PQNode<edge,indInfo*,bool> *nodePtr) const { PQNode<edge,indInfo*,bool> *right = PQTree<edge,indInfo*,bool>::clientRightEndmost(nodePtr); if (!right || right->status() != INDICATOR) return right; else return clientNextSib(right,NULL); }
// Overloads virtual function of base class PQTree // Allows ignoring the virtual direction indicators during // the template matching algorithm. PQNode<edge,indInfo*,bool>* EmbedPQTree::clientLeftEndmost( PQNode<edge,indInfo*,bool> *nodePtr) const { PQNode<edge,indInfo*,bool> *left = PQTree<edge,indInfo*,bool>::clientLeftEndmost(nodePtr); if (!left || left->status() != INDICATOR) return left; else return clientNextSib(left,NULL); }
// Overloads virtual function of base class PQTree // Allows ignoring the virtual direction indicators during // the template matching algorithm. PQNode<edge,IndInfo*,bool>* EmbedPQTree::clientRightEndmost( PQNode<edge,IndInfo*,bool> *nodePtr) const { PQNode<edge,IndInfo*,bool> *right = PQTree<edge,IndInfo*,bool>::clientRightEndmost(nodePtr); if (!right || right->status() != PQNodeRoot::PQNodeStatus::Indicator) return right; else return clientNextSib(right,nullptr); }
// Overloads virtual function of base class PQTree // Allows ignoring the virtual direction indicators during // the template matching algorithm. PQNode<edge,IndInfo*,bool>* EmbedPQTree::clientLeftEndmost( PQNode<edge,IndInfo*,bool> *nodePtr) const { PQNode<edge,IndInfo*,bool> *left = PQTree<edge,IndInfo*,bool>::clientLeftEndmost(nodePtr); if (!left || left->status() != PQNodeRoot::PQNodeStatus::Indicator) return left; else return clientNextSib(left,nullptr); }
// The function [[emptyAllPertinentNodes]] has to be called after a reduction // has been processed. This overloaded function first destroys all full nodes // by marking them as TO_BE_DELETED and then calling the base class function // [[emptyAllPertinentNodes]]. void PlanarPQTree::emptyAllPertinentNodes() { ListIterator<PQNode<edge,indInfo*,bool>*> it; for (it = m_pertinentNodes->begin(); it.valid(); it++) { PQNode<edge,indInfo*,bool>* nodePtr = (*it); if (nodePtr->status() == FULL) destroyNode(nodePtr); } if (m_pertinentRoot) m_pertinentRoot->status(FULL); PQTree<edge,indInfo*,bool>::emptyAllPertinentNodes(); }
void PlanarSubgraphPQTree:: removeEliminatedLeaves(SList<PQLeafKey<edge,whaInfo*,bool>*> &eliminatedKeys) { PQNode<edge,whaInfo*,bool>* nodePtr = 0; PQNode<edge,whaInfo*,bool>* parent = 0; PQNode<edge,whaInfo*,bool>* sibling = 0; SListIterator<PQLeafKey<edge,whaInfo*,bool>*> it; for (it = eliminatedKeys.begin(); it.valid(); it++) { nodePtr = (*it)->nodePointer(); parent = nodePtr->parent(); sibling = nodePtr->getNextSib(NULL); removeNodeFromTree(parent,nodePtr); checkIfOnlyChild(sibling,parent); if (parent->status() == TO_BE_DELETED) { parent->status(WHA_DELETE); } nodePtr->status(WHA_DELETE); } }
// The function [[emptyAllPertinentNodes]] has to be called after a reduction // has been processed. This overloaded function first destroys all full nodes // by marking them as TO_BE_DELETED and then calling the base class function // [[emptyAllPertinentNodes]]. void EmbedPQTree::emptyAllPertinentNodes() { ListIterator<PQNode<edge,indInfo*,bool>*> it; for (it = m_pertinentNodes->begin(); it.valid(); it++) { PQNode<edge,indInfo*,bool>* nodePtr = (*it); if (nodePtr->status() == FULL) destroyNode(nodePtr); } if (m_pertinentRoot) // Node was kept in the tree. Do not free it. m_pertinentRoot->status(FULL); PQTree<edge,indInfo*,bool>::emptyAllPertinentNodes(); }
// The function front scans the frontier of nodePtr. It returns the keys // of the leaves found in the frontier of nodePtr in a SListPure. // These keys include keys of direction indicators detected in the frontier. // // CAREFUL: Funktion marks all full nodes for destruction. // Only to be used in connection with replaceRoot. // void EmbedPQTree::front( PQNode<edge,indInfo*,bool>* nodePtr, SListPure<PQBasicKey<edge,indInfo*,bool>*> &keys) { Stack<PQNode<edge,indInfo*,bool>*> S; S.push(nodePtr); while (!S.empty()) { PQNode<edge,indInfo*,bool> *checkNode = S.pop(); if (checkNode->type() == PQNodeRoot::leaf) keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) checkNode->getKey()); else { PQNode<edge,indInfo*,bool>* firstSon = 0; if (checkNode->type() == PQNodeRoot::PNode) { firstSon = checkNode->referenceChild(); } else if (checkNode->type() == PQNodeRoot::QNode) { firstSon = checkNode->getEndmost(RIGHT); // By this, we make sure that we start on the left side // since the left endmost child will be on top of the stack } if (firstSon->status() == INDICATOR) { keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) firstSon->getNodeInfo()); m_pertinentNodes->pushBack(firstSon); destroyNode(firstSon); } else S.push(firstSon); PQNode<edge,indInfo*,bool> *nextSon = firstSon->getNextSib(0); PQNode<edge,indInfo*,bool> *oldSib = firstSon; while (nextSon && nextSon != firstSon) { if (nextSon->status() == INDICATOR) { // Direction indicators point with their left sibling pointer // in the direction of their sequence. If an indicator is scanned // from the opposite direction, coming from its right sibling // the corresponding sequence must be reversed. if (oldSib == nextSon->getSib(LEFT)) //Direction changed nextSon->getNodeInfo()->userStructInfo()->changeDir = true; keys.pushBack((PQBasicKey<edge,indInfo*,bool>*) nextSon->getNodeInfo()); m_pertinentNodes->pushBack(nextSon); } else S.push(nextSon); PQNode<edge,indInfo*,bool> *holdSib = nextSon->getNextSib(oldSib); oldSib = nextSon; nextSon = holdSib; } } } }