|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
52 template<
class T,
class X,
class Y>
173 void writeGML(
const char* fileName);
791 template<
class T,
class X,
class Y>
794 if (!leafKeys.empty()) {
811 for (++it; it.
valid(); ++it) {
841 template<
class T,
class X,
class Y>
847 if (child !=
nullptr) {
876 template<
class T,
class X,
class Y>
879 if (parent !=
nullptr) {
883 if (leftBrother ==
nullptr && rightBrother ==
nullptr) {
884 return addNodeToNewParent(parent, child);
885 }
else if (child !=
nullptr) {
900 PQNode<T, X, Y>* brother = (leftBrother !=
nullptr) ? leftBrother : rightBrother;
909 else if (leftBrother ==
nullptr) {
938 else if (rightBrother ==
nullptr) {
1005 }
else if (leftBrother !=
nullptr && rightBrother !=
nullptr) {
1044 template<
class T,
class X,
class Y>
1080 for (it = leafKeys.begin(); it.
valid(); ++it) {
1083 processNodes.
append(checkLeaf);
1084 m_pertinentNodes->pushFront(checkLeaf);
1093 while ((processNodes.
size() + blockCount + offTheTop) > 1) {
1094 if (processNodes.
size() == 0) {
1116 blockedNodes.
push(checkNode);
1118 int blockedSiblings = 0;
1131 if (clientSibLeft(checkNode) ==
nullptr)
1137 if (clientSibRight(checkNode)
1143 else if (clientSibRight(checkNode) ==
nullptr)
1149 if (clientSibLeft(checkNode)
1166 checkNode->
m_parent = clientSibLeft(checkNode)->m_parent;
1176 checkNode->
m_parent = clientSibRight(checkNode)->m_parent;
1211 if (blockedSiblings > 0) {
1212 if (clientSibLeft(checkNode) !=
nullptr) {
1213 checkSib = clientSibLeft(checkNode);
1227 if (clientSibRight(checkNode) !=
nullptr) {
1228 checkSib = clientSibRight(checkNode);
1258 if (parent ==
nullptr) {
1266 processNodes.
append(parent);
1267 m_pertinentNodes->pushFront(parent);
1272 blockCount -= blockedSiblings;
1273 blockedSiblings = 0;
1282 blockCount += 1 - blockedSiblings;
1287 if (blockCount == 1) {
1306 while (!blockedNodes.
empty()) {
1310 checkNode->
m_parent = m_pseudoRoot;
1311 m_pseudoRoot->m_pertChildCount++;
1321 template<
class T,
class X,
class Y>
1344 bool notFull =
false;
1354 (*seqEnd) = firstFull;
1355 if (leftNext !=
nullptr) {
1362 while (fullCount > 0 && !notFull)
1367 leftNext = clientNextSib(checkNode, leftOld);
1373 leftOld = checkNode;
1374 checkNode = leftNext;
1378 (*seqEnd) = checkNode;
1385 (*seqEnd) = leftOld;
1389 (*seqEnd) = firstFull;
1400 (*seqStart) = firstFull;
1401 if (rightNext !=
nullptr) {
1408 while (fullCount > 0 && !notFull)
1413 rightNext = clientNextSib(checkNode, rightOld);
1419 rightOld = checkNode;
1420 checkNode = rightNext;
1423 (*seqStart) = checkNode;
1429 (*seqStart) = rightOld;
1434 (*seqStart) = firstFull;
1438 if (firstFull == (*seqEnd)) {
1440 (*seqEnd) = (*seqStart);
1441 (*seqStart) = checkNode;
1444 if (fullCount == 0) {
1453 template<
class T,
class X,
class Y>
1458 removeChildFromSiblings(child);
1461 exchangeNodes(parent, child);
1463 exchangeNodes(parent, child);
1466 destroyNode(parent);
1473 template<
class T,
class X,
class Y>
1498 if (m_root !=
nullptr) {
1499 emptyAllPertinentNodes();
1508 if (m_root->m_referenceChild !=
nullptr) {
1510 helpqueue.
append(firstSon);
1515 while (nextSon != firstSon) {
1516 helpqueue.
append(nextSon);
1522 helpqueue.
append(firstSon);
1525 helpqueue.
append(lastSon);
1529 while (nextSon != firstSon) {
1530 helpqueue.
append(nextSon);
1541 while (!helpqueue.
empty()) {
1552 helpqueue.
append(firstSon);
1557 while (nextSon != firstSon) {
1558 helpqueue.
append(nextSon);
1566 helpqueue.
append(firstSon);
1569 helpqueue.
append(lastSon);
1573 while (nextSon != firstSon) {
1574 helpqueue.
append(nextSon);
1581 CleanNode(checkNode);
1586 CleanNode(m_pseudoRoot);
1587 delete m_pseudoRoot;
1589 delete m_pertinentNodes;
1592 m_pertinentRoot =
nullptr;
1593 m_pseudoRoot =
nullptr;
1594 m_pertinentNodes =
nullptr;
1596 m_numberOfLeaves = 0;
1597 m_identificationNumber = 0;
1600 template<
class T,
class X,
class Y>
1602 return (nodePtr !=
nullptr) ? 1 : 0;
1606 template<
class T,
class X,
class Y>
1608 return (nodePtr !=
nullptr) ?
"ERROR" :
"ERROR: clientPrintStatus: NO NODE ACCESSED";
1611 template<
class T,
class X,
class Y>
1613 return (nodePtr !=
nullptr) ?
"ERROR" :
"ERROR: clientPrintType: NO NODE ACCESSED";
1616 template<
class T,
class X,
class Y>
1619 m_pertinentRoot =
nullptr;
1620 m_pseudoRoot =
nullptr;
1622 m_numberOfLeaves = 0;
1623 m_identificationNumber = 0;
1625 m_pertinentNodes =
nullptr;
1628 template<
class T,
class X,
class Y>
1647 linkChildrenOfQnode(checkNode, newNode);
1655 linkChildrenOfQnode(checkNode, newNode);
1663 template<
class T,
class X,
class Y>
1679 if (fullNodes->size() == 1) {
1684 newNode = fullNodes->popFrontRet();
1685 removeChildFromSiblings(newNode);
1701 m_pertinentNodes->pushFront(newNode);
1710 removeChildFromSiblings(firstSon);
1724 while (!fullNodes->empty()) {
1726 removeChildFromSiblings(checkSon);
1743 template<
class T,
class X,
class Y>
1745 while (!m_pertinentNodes->empty()) {
1747 switch (nodePtr->
status()) {
1749 if (nodePtr == m_root) {
1766 clientDefinedEmptyNode(nodePtr);
1770 m_pseudoRoot->m_pertChildCount = 0;
1771 m_pseudoRoot->m_pertLeafCount = 0;
1772 m_pseudoRoot->fullChildren->clear();
1773 m_pseudoRoot->partialChildren->clear();
1778 template<
class T,
class X,
class Y>
1788 template<
class T,
class X,
class Y>
1809 if (oldNode->
m_parent->m_leftEndmost == oldNode) {
1810 oldNode->
m_parent->m_leftEndmost = newNode;
1811 }
else if (oldNode->
m_parent->m_rightEndmost == oldNode) {
1812 oldNode->
m_parent->m_rightEndmost = newNode;
1832 if (oldNode->
m_parent ==
nullptr) {
1852 if (oldNode->
m_sibLeft->m_sibRight == oldNode) {
1853 oldNode->
m_sibLeft->m_sibRight = newNode;
1857 oldNode->
m_sibLeft->m_sibLeft = newNode;
1864 if (oldNode->
m_sibRight->m_sibLeft == oldNode) {
1879 template<
class T,
class X,
class Y>
1882 helpqueue.
append(nodePtr);
1884 while (!helpqueue.
empty()) {
1888 leafKeys.pushBack(checkNode->
getKey());
1902 helpqueue.
append(firstSon);
1905 while (nextSon && nextSon != firstSon) {
1906 helpqueue.
append(nextSon);
1915 template<
class T,
class X,
class Y>
1919 if (!leafKeys.empty()) {
1922 m_pseudoRoot = newNode2;
1924 if (leafKeys.begin() != leafKeys.end())
1930 m_root->m_sibRight = m_root;
1931 return addNewLeavesToTree(newNode, leafKeys);
1937 m_root->m_sibRight = m_root;
1944 template<
class T,
class X,
class Y>
1946 if (installed !=
nullptr && newChild !=
nullptr) {
1968 template<
class T,
class X,
class Y>
1970 std::ofstream os(fileName);
1974 template<
class T,
class X,
class Y>
1982 os.setf(std::ios::showpoint);
1985 os <<
"Creator \"ogdf::PQTree::writeGML\"\n";
1987 os <<
" directed 1\n";
2006 if (checkNode->
getKey() != 0) {
2007 checkNode->
getKey()->print(os);
2011 os <<
" graphics [\n";
2014 os <<
" fill \"#FF0000\"\n";
2016 os <<
" fill \"#0000A0\"\n";
2018 os <<
"fill \"#FFFFE6\"\n";
2022 os <<
" fill \"#FF0000\"\n";
2024 os <<
" fill \"#0000A0\"\n";
2026 os <<
" fill \"#00FF00\"\n";
2030 os <<
" fill \"#FF0000\"\n";
2032 os <<
" fill \"#0000A0\"\n";
2034 os <<
" fill \"#FFFFE6\"\n";
2038 os <<
" fill \"#FF0000\"\n";
2040 os <<
" fill \"#0000A0\"\n";
2042 os <<
" fill \"#FFFFE6\"\n";
2057 while (nextSon != firstSon) {
2070 if (firstSon != lastSon) {
2074 while (nextSon != firstSon) {
2082 if (!helpQueue.
empty()) {
2095 for (it = secondTrace.
begin(); it.
valid(); ++it) {
2108 while (nextSon != firstSon) {
2127 if (firstSon != lastSon) {
2135 while (nextSon != firstSon) {
2150 template<
class T,
class X,
class Y>
2166 int pertLeafCount = 0;
2176 for (it = leafKeys.begin(); it.
valid(); ++it) {
2180 processNodes.
append(checkLeaf);
2185 while (checkNode !=
nullptr && processNodes.
size() > 0) {
2186 checkNode = processNodes.
pop();
2201 checkNode->
m_parent->m_pertLeafCount =
2204 checkNode->
m_parent->m_pertChildCount--;
2205 if (!checkNode->
m_parent->m_pertChildCount) {
2208 if (!templateL1(checkNode, 0) && !templateP1(checkNode, 0) && !templateP3(checkNode)
2209 && !templateP5(checkNode) && !templateQ1(checkNode, 0)
2210 && !templateQ2(checkNode, 0)) {
2211 checkNode =
nullptr;
2224 if (!templateL1(checkNode, 1) && !templateP1(checkNode, 1) && !templateP2(&checkNode)
2225 && !templateP4(&checkNode) && !templateP6(&checkNode) && !templateQ1(checkNode, 1)
2226 && !templateQ2(checkNode, 1) && !templateQ3(checkNode)) {
2227 checkNode =
nullptr;
2232 m_pertinentRoot = checkNode;
2233 return m_pertinentRoot !=
nullptr;
2236 template<
class T,
class X,
class Y>
2241 bool success = Bubble(leafKeys);
2246 return Reduce(leafKeys);
2250 template<
class T,
class X,
class Y>
2410 int endmostcheck = 0;
2415 nodePtr->
m_parent->partialChildren->pushFront(nodePtr);
2424 checkVarLeft = clientLeftEndmost(partial_1);
2425 checkVarRight = clientRightEndmost(partial_1);
2428 realfull_1 = checkVarLeft;
2434 realfull_1 = checkVarRight;
2439 realempty_1 = checkVarLeft;
2445 realempty_1 = checkVarRight;
2451 if (clientSibLeft(partial_1) !=
nullptr) {
2463 if (clientSibRight(partial_1) !=
nullptr) {
2485 checkVarLeft = clientLeftEndmost(partial_2);
2486 checkVarRight = clientRightEndmost(partial_2);
2498 realempty_2 = checkVarLeft;
2504 realempty_2 = checkVarRight;
2509 if (clientSibLeft(partial_2) !=
nullptr) {
2522 if (clientSibRight(partial_2) !=
nullptr) {
2537 if (partial_1 !=
nullptr && partial_2 !=
nullptr)
2553 if (sibfull_1 !=
nullptr && sibfull_2 !=
nullptr)
2567 else if (sibpartial_1 !=
nullptr && sibpartial_2 !=
nullptr)
2573 if (partial_1 == sibpartial_2 && partial_2 == sibpartial_1)
2593 if (sibempty_1 ==
nullptr)
2599 if (nonstatussib_1 ==
nullptr)
2622 if (sibempty_2 ==
nullptr)
2628 if (nonstatussib_2 ==
nullptr)
2660 destroyNode(partial_2);
2668 destroyNode(partial_1);
2672 else if (partial_1 !=
nullptr)
2688 if ((clientLeftEndmost(nodePtr) == partial_1) || (clientRightEndmost(nodePtr) == partial_1)) {
2693 if (sibfull_1 !=
nullptr)
2704 else if (!endmostcheck)
2712 if (partial_1->
m_sibLeft != sibempty_1) {
2729 if (nonstatussib_1 ==
nullptr)
2745 if (sibempty_1 ==
nullptr)
2752 if (nonstatussib_1 ==
nullptr)
2783 destroyNode(partial_1);
2788 template<
class T,
class X,
class Y>
2810 if (nodePtr->
m_parent->m_leftEndmost == nodePtr) {
2811 nodePtr->
m_parent->m_leftEndmost = sibling;
2812 }
else if (nodePtr->
m_parent->m_rightEndmost == nodePtr) {
2813 nodePtr->
m_parent->m_rightEndmost = sibling;
2815 if (sibling !=
nullptr) {
2825 if (nodePtr->
m_sibRight->m_sibLeft == nodePtr) {
2834 if (nodePtr->
m_sibLeft->m_sibRight == nodePtr) {
2847 template<
class T,
class X,
class Y>
2849 if (parent !=
nullptr) {
2850 removeChildFromSiblings(child);
2863 template<
class T,
class X,
class Y>
2865 bool changed =
true;
2868 for (
int i = 0; i < (arraySize - 1); i++) {
2869 if (Exceptions[i] > Exceptions[i + 1]) {
2870 std::swap(Exceptions[i], Exceptions[i + 1]);
2877 template<
class T,
class X,
class Y>
2882 nodePtr->
m_parent->fullChildren->pushFront(nodePtr);
2890 template<
class T,
class X,
class Y>
2898 nodePtr->
m_parent->fullChildren->pushFront(nodePtr);
2905 template<
class T,
class X,
class Y>
2908 || (*nodePtr)->partialChildren->size() > 0) {
2912 (*nodePtr)->m_childCount = (*nodePtr)->m_childCount - (*nodePtr)->fullChildren->size() + 1;
2917 PQNode<T, X, Y>* newNode = createNodeAndCopyFullChildren((*nodePtr)->fullChildren);
2922 newNode->
m_sibRight = (*nodePtr)->m_referenceChild->m_sibRight;
2924 newNode->
m_sibLeft->m_sibRight = newNode;
2929 (*nodePtr) = newNode;
2934 template<
class T,
class X,
class Y>
2957 m_pertinentNodes->pushFront(newQnode);
2959 exchangeNodes(nodePtr, newQnode);
2992 checkIfOnlyChild(emptyNode, nodePtr);
2995 newQnode->
m_parent->partialChildren->pushFront(newQnode);
3000 template<
class T,
class X,
class Y>
3003 || (*nodePtr)->partialChildren->size() != 1) {
3008 copyFullChildrenToPartial(*nodePtr, partialChild);
3013 checkIfOnlyChild(partialChild, *nodePtr);
3016 *nodePtr = partialChild;
3021 template<
class T,
class X,
class Y>
3058 nodePtr->
m_parent->partialChildren->pushFront(partialChild);
3059 removeChildFromSiblings(partialChild);
3060 exchangeNodes(nodePtr, partialChild);
3061 copyFullChildrenToPartial(nodePtr, partialChild);
3063 if (emptyChildCount > 0) {
3073 if (emptyChildCount == 1) {
3075 removeChildFromSiblings(emptyNode);
3078 emptyNode = nodePtr;
3100 linkChildrenOfQnode(checkNode, emptyNode);
3101 emptyNode->
m_parent = partialChild;
3107 if (emptyChildCount <= 1) {
3108 destroyNode(nodePtr);
3114 template<
class T,
class X,
class Y>
3142 || (*nodePtr)->partialChildren->size() != 2) {
3157 removeChildFromSiblings(partial_2);
3158 (*nodePtr)->m_childCount--;
3159 copyFullChildrenToPartial(*nodePtr, partial_1);
3185 realEmptyEnd_2 = clientLeftEndmost(partial_2);
3195 realEmptyEnd_2 = clientRightEndmost(partial_2);
3213 linkChildrenOfQnode(fullEnd_1, fullEnd_2);
3223 realEmptyEnd_2->
m_parent = partial_1;
3227 destroyNode(partial_2);
3233 checkIfOnlyChild(partial_1, *nodePtr);
3236 *nodePtr = partial_1;
3241 template<
class T,
class X,
class Y>
3248 if (checkChain(nodePtr, clientLeftEndmost(nodePtr), &seqStart, &seqEnd)) {
3251 nodePtr->
m_parent->fullChildren->pushFront(nodePtr);
3260 template<
class T,
class X,
class Y>
3289 bool sequenceCons =
false;
3297 fullNode = clientLeftEndmost(nodePtr);
3303 fullNode = clientRightEndmost(nodePtr);
3325 if (fullNode !=
nullptr) {
3326 sequenceCons = checkChain(nodePtr, fullNode, &sequenceBegin, &sequenceEnd);
3331 sequenceCons =
false;
3333 if (clientSibLeft(sequenceEnd) == partialChild
3334 || clientSibRight(sequenceEnd) == partialChild) {
3335 sequenceCons =
true;
3352 if ((clientLeftEndmost(nodePtr) == partialChild)
3353 || (clientRightEndmost(nodePtr) == partialChild)) {
3354 sequenceCons =
true;
3360 removeBlock(nodePtr, isRoot);
3363 return sequenceCons;
3366 template<
class T,
class X,
class Y>
3395 bool conssequence =
false;
3426 conssequence = checkChain(nodePtr, fullChild, &fullStart, &fullEnd);
3432 if ((clientSibLeft(fullStart) == partial_1)
3433 || (clientSibRight(fullStart) == partial_1)
3434 || (clientSibLeft(fullEnd) == partial_1)
3435 || (clientSibRight(fullEnd) == partial_1)) {
3439 conssequence = found;
3452 if ((clientSibLeft(partial_1) == partial_2) || (clientSibRight(partial_1) == partial_2)) {
3455 conssequence = found;
3459 removeBlock(nodePtr,
true);
3462 return conssequence;
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
virtual int removeNodeFromTree(PQNode< T, X, Y > *parent, PQNode< T, X, Y > *child)
The objective is to remove a node child from the PQ-tree.
The class template PQInternalNode is used to present P-nodes and Q-nodes in the PQ-Tree.
The namespace for all OGDF objects.
virtual bool addNodeToNewParent(PQNode< T, X, Y > *parent, PQNode< T, X, Y > *child)
Adds a node child as a child to another node specified in parent.
Declaration and implementation of ArrayBuffer class.
iterator append(const E &x)
Adds x at the end of queue.
void writeGML(const char *fileName)
The function writeGML() prints the PQ-tree in the GML fileformat.
virtual bool templateP4(PQNode< T, X, Y > **nodePtr)
Template matching for a P-node with full, empty and exactly one partial children.
int m_identificationNumber
Each node that has been introduced once into the tree gets a unique number.
Declaration and implementation of the class PQNode.
PQNode< T, X, Y > * m_referenceChild
Stores a pointer to one child, the reference child of the doubly linked cirkular list of children of ...
List< PQNode< T, X, Y > * > * partialChildren(PQNode< T, X, Y > *nodePtr)
virtual void destroyNode(PQNode< T, X, Y > *nodePtr)
Marks a node as PQNodeRoot::PQNodeStatus::ToBeDeleted.
virtual bool templateP1(PQNode< T, X, Y > *nodePtr, bool isRoot)
Template matching for P-nodes with only full children.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
bool empty() const
Returns true if the buffer is empty, false otherwise.
int m_numberOfLeaves
Stores the number of leaves.
List< PQNode< T, X, Y > * > * fullChildren(PQNode< T, X, Y > *nodePtr)
void sortExceptions(int Exceptions[], int arraySize)
Sorts the exceptions before frontExcept() scans the frontier.
List< PQNode< T, X, Y > * > * fullChildren
Stores all full children of a node during a reduction.
The class template PQLeafKey is a derived class of class template PQBasicKey.
Encapsulates a pointer to an ogdf::SList element.
virtual PQNode< T, X, Y > * clientNextSib(PQNode< T, X, Y > *nodePtr, PQNode< T, X, Y > *other) const
PQNode< T, X, Y > * m_referenceParent
Is a pointer to the parent, in case that the parent is a P-node and the node itself is its reference ...
virtual bool templateQ2(PQNode< T, X, Y > *nodePtr, bool isRoot)
Template matching for Q-nodes with a pertinent sequence of children on one side of the Q-node.
bool valid() const
Returns true iff the iterator points to an element.
const_reference top() const
Returns a reference to the front element.
virtual void clientDefinedEmptyNode(PQNode< T, X, Y > *nodePtr)
If the user wishes to use different flags in a derived class of PQTree that are not available in this...
Declaration and implementation of list-based queues (classes QueuePure<E> and Queue<E>).
virtual bool templateL1(PQNode< T, X, Y > *nodePtr, bool isRoot)
Template matching for leaves.
virtual bool templateP6(PQNode< T, X, Y > **nodePtr)
Template matching for a P-node with full, empty and exactly two partial children.
virtual PQNodeMark mark() const =0
mark() returns the variable PQLeaf::m_mark in the derived class PQLeaf and PQInternalNode.
virtual const char * clientPrintType(PQNode< T, X, Y > *nodePtr)
If the user wishes to use different types in a derived class of PQTree that are not available in this...
virtual PQNode< T, X, Y > * clientLeftEndmost(PQNode< T, X, Y > *nodePtr) const
E popRet()
Removes the newest element from the buffer and returns it.
Declaration and implementation of the class PQNodeRoot.
virtual bool templateP3(PQNode< T, X, Y > *nodePtr)
Template matching for a P-node with full and empty children that is not the root of the pertinent sub...
virtual void Cleanup()
Removes the entire PQ-tree.
bool valid() const
Returns true iff the iterator points to an element.
virtual PQNode< T, X, Y > * clientSibLeft(PQNode< T, X, Y > *nodePtr) const
virtual bool templateQ3(PQNode< T, X, Y > *nodePtr)
PQNode< T, X, Y > * m_rightEndmost
Stores the right endmost child of a Q-node.
virtual void emptyAllPertinentNodes()
Cleans up all flags that have been set in the pertinent nodes during the reduction process.
iterator begin()
Returns an iterator to the first element of the list.
PQNode< T, X, Y > * m_pseudoRoot
a pointer to the virtual root of the pertinent subtree, in case that the pertinent root cannot be det...
PQNode< T, X, Y > * m_sibLeft
Stores a pointer ot the left sibling of PQNode.
virtual bool templateP2(PQNode< T, X, Y > **nodePtr)
Template matching for a P-node with full and empty children that is the root of the pertinent subtree...
bool empty() const
Returns true iff the list is empty.
virtual ~PQTree()
Destructor.
virtual const char * clientPrintStatus(PQNode< T, X, Y > *nodePtr)
If the user wishes to use different status in a derived class of PQTree that are not available in thi...
virtual PQLeafKey< T, X, Y > * getKey() const =0
getKey() returns a pointer to the PQLeafKeyof a node, in case that the node is supposed to have a key...
virtual void front(PQNode< T, X, Y > *nodePtr, SListPure< PQLeafKey< T, X, Y > * > &leafKeys)
Returns the keys stored in the leaves of the front of nodePtr.
void copyFullChildrenToPartial(PQNode< T, X, Y > *nodePtr, PQNode< T, X, Y > *partialChild)
Copies all full children of nodePtr to a new P-node The node nodePtr has to be a P-node.
The datastructure PQ-tree was designed to present a set of permutations on an arbitrary set of elemen...
E pop()
Removes front element and returns it.
Declaration of singly linked lists and iterators.
List< PQNode< T, X, Y > * > * partialChildren
Stores all partial children of a node during a reduction.
int size() const
Returns the number of elements in the queue.
virtual PQNode< T, X, Y > * clientRightEndmost(PQNode< T, X, Y > *nodePtr) const
PQNodeType m_parentType
Stores the type of the parent which can be either a P- or Q-node.
PQNode< T, X, Y > * m_root
a pointer to the root of the $PQ$-tree.
virtual PQNodeStatus status() const =0
Returns the variable PQLeaf::m_status in the derived class PQLeaf and PQInternalNode.
PQNode< T, X, Y > * getNextSib(PQNode< T, X, Y > *other) const
The function getNextSib() returns one of the siblings of the node.
void push(E e)
Puts a new element in the buffer.
virtual PQNode< T, X, Y > * clientSibRight(PQNode< T, X, Y > *nodePtr) const
virtual int Initialize(SListPure< PQLeafKey< T, X, Y > * > &leafKeys)
Initializes the PQ-tree with a set of elements.
bool changeSiblings(PQNode< T, X, Y > *oldSib, PQNode< T, X, Y > *newSib)
The function changeSiblings() replaces the old sibling oldSib of the node by a new sibling newSib.
virtual void CleanNode(PQNode< T, X, Y > *)
Doubly linked lists (maintaining the length of the list).
SibDirection putSibling(PQNode< T, X, Y > *newSib)
The default function putSibling() stores a new sibling at a free sibling pointer of the node.
The parameterized class Queue<E> implements list-based queues.
Declaration and implementation of the class PQLeafKey.
int m_identificationNumber
Stores the total number of nodes that have been allocated.
virtual PQNodeType type() const =0
Returns the variable PQInternalNode::m_type in the derived class PQLeaf and PQInternalNode.
virtual void exchangeNodes(PQNode< T, X, Y > *oldNode, PQNode< T, X, Y > *newNode)
Replaces the oldNode by the newNode in the tree.
virtual bool templateQ1(PQNode< T, X, Y > *nodePtr, bool isRoot)
Template matching for Q-nodes with only full children.
bool addNewLeavesToTree(PQInternalNode< T, X, Y > *father, SListPure< PQLeafKey< T, X, Y > * > &leafKeys)
Adds a set of elements to the already existing set of elements of a PQ-tree.
bool empty() const
Returns true iff the queue is empty.
E popFrontRet()
Removes the first element from the list and returns it.
virtual PQNodeRoot::PQNodeType type() const
Returns the variable m_type in the derived class PQInternalNode.
PQNode< T, X, Y > * m_pertinentRoot
a pointer to the root of the pertinent subtree.
void emptyNode(PQNode< T, X, Y > *nodePtr)
Cleans up all stacks, flags and pointers of a pertinent node that has been visited during the reducti...
virtual bool templateP5(PQNode< T, X, Y > *nodePtr)
Template matching for a P-node with full, empty children and exactly one partial child.
int m_pertChildCount
Stores the number of pertinent children of the node.
virtual bool checkIfOnlyChild(PQNode< T, X, Y > *child, PQNode< T, X, Y > *parent)
Checks if child is the only child of parent.
Basic declarations, included by all source files.
int m_pertLeafCount
Stores the number of pertinent leaves in the frontier of the node.
Declaration and implementation of Array class and Array algorithms.
Declaration and implementation of the class PQleaf.
PQNode< T, X, Y > * root() const
Returns a pointer of the root node of the PQTree.
Declaration of doubly linked lists and iterators.
List< PQNode< T, X, Y > * > * m_pertinentNodes
Stores all nodes that have been marked PQNodeRoot::PQNodeStatus::Full or PQNodeRoot::PQNodeStatus::Pa...
virtual bool Reduction(SListPure< PQLeafKey< T, X, Y > * > &leafKeys)
Tests whether permissible permutations of the elements of U exist such that the elements of a subset ...
PQNode< T, X, Y > * m_leftEndmost
virtual bool Reduce(SListPure< PQLeafKey< T, X, Y > * > &leafKeys)
Performs the reduction of the pertinent leaves with the help of the template matchings,...
void removeBlock(PQNode< T, X, Y > *nodePtr, bool isRoot)
Of every partial node that is found in the sequence of children of nodePtr, all children are removed ...
iterator pushBack(const E &x)
Adds element x at the end of the list.
bool endmostChild() const
The function endmostChild() checks if a node is endmost child of a Q-node.
virtual bool Bubble(SListPure< PQLeafKey< T, X, Y > * > &leafKeys)
Realizes a function described in [Booth].
Declaration and implementation of the class PQInternalNode.
Encapsulates a pointer to a list element.
virtual void linkChildrenOfQnode(PQNode< T, X, Y > *installed, PQNode< T, X, Y > *newChild)
Links the two endmost children of two different Q-nodes via their sibling pointers together.
bool checkChain(PQNode< T, X, Y > *nodePtr, PQNode< T, X, Y > *firstFull, PQNode< T, X, Y > **seqStart, PQNode< T, X, Y > **seqEnd)
Checks whether all full children of a Q-node nodePtr form a consecutive sequence.
PQNode< T, X, Y > * createNodeAndCopyFullChildren(List< PQNode< T, X, Y > * > *fullNodes)
Copies the full children of a P-node that are stored in the stack fullNodes to a new P-node.
virtual void removeChildFromSiblings(PQNode< T, X, Y > *nodePtr)
Removes the node nodePtr from the doubly linked list of its parent.
PQNode< T, X, Y > * m_sibRight
Stores a pointer ot the right sibling of PQNode.
PQNode< T, X, Y > * m_parent
Is a pointer to the parent.
bool changeEndmost(PQNode< T, X, Y > *oldEnd, PQNode< T, X, Y > *newEnd)
The function changeEndmost() replaces the old endmost child oldEnd of the node by a new child newEnd.
virtual int clientPrintNodeCategorie(PQNode< T, X, Y > *nodePtr)
If the user wishes to use different flags in a derived class of PQTree that are not available in this...
The class template PQBasicKey is an abstract base class.