95 template<
class T,
class Y>
394 template<
class T,
class Y>
409 for (it = leafKeys.begin(); it.
valid(); ++it)
412 processNodes.
append(checkLeaf);
433 while (!processNodes.
empty())
448 if (nodePtr != this->
m_root)
482 template<
class T,
class Y>
492 template<
class T,
class Y>
509 template<
class T,
class Y>
516 nodePtr =
cleanUp.popFrontRet();
552 template<
class T,
class Y>
560 int countDeletedLeaves = 0;
562 int maxPertLeafCount = 0;
579 for (it = leafKeys.begin(); it.
valid(); ++it)
584 processNodes.
append(checkLeaf);
585 archiv.
push(checkLeaf);
590 while (!processNodes.
empty())
592 nodePtr = processNodes.
pop();
676 if (countDeletedLeaves > 0)
687 return countDeletedLeaves;
690 template<
class T,
class Y>
707 while (!archiv.empty())
737 eliminatedKeys.pushBack(nodePtr->
getKey());
928 template<
class T,
class Y>
932 int pertinentChildCount = 0;
935 bool fullLabel =
false;
941 if (hChild1 !=
nullptr)
958 nextSibling = currentNode->
getNextSib(oldSibling);
965 pertinentChildCount++;
975 pertinentChildCount++;
979 oldSibling = currentNode;
980 currentNode = nextSibling;
983 return pertinentChildCount;
986 template<
class T,
class Y>
1001 int pertinentChildCount = 0;
1018 pertinentChildCount++;
1023 nextSibling = hChild2Sib;
1024 oldSibling = hChild2;
1026 if (nextSibling !=
nullptr)
1028 currentNode = nextSibling;
1031 bool reachedEnd =
false;
1038 pertinentChildCount++;
1047 pertinentChildCount++;
1053 nextSibling = currentNode->
getNextSib(oldSibling);
1054 if (nextSibling ==
nullptr)
1056 oldSibling = currentNode;
1057 currentNode = nextSibling;
1062 return pertinentChildCount;
1065 template<
class T,
class Y>
1083 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1085 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1091 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1098 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1102 template<
class T,
class Y>
1146 currentNode = (*it);
1150 if (sumMax1 <= sumHelp)
1155 hChild1 = currentNode;
1157 else if (sumMax2 <= sumHelp)
1160 hChild2 = currentNode;
1183 int alpha2 = sumParW - sumMax1 - sumMax2;
1186 if (alpha1 <= alpha2)
1198 template<
class T,
class Y>
1211 template<
class T,
class Y>
1239 bool fullLabel =
true;
1275 checkSibling = leftChild->
getNextSib(holdSibling);
1276 if (checkSibling ==
nullptr)
1278 holdSibling = leftChild;
1279 leftChild = checkSibling;
1296 holdSibling =
nullptr;
1297 checkSibling =
nullptr;
1305 sumRight = sumRight +
1309 checkSibling = rightChild->
getNextSib(holdSibling);
1311 if (checkSibling ==
nullptr)
1314 holdSibling = rightChild;
1315 rightChild = checkSibling;
1329 if (sumLeft == 0 && sumRight == 0)
1334 else if (sumLeft < sumRight)
1346 template<
class T,
class Y>
1381 bool endReached = 0;
1408 if (sequence.
empty())
1460 while (!sequence.
empty())
1465 if (sequence.
size() == 1)
1466 leftSib = currentNode;
1468 leftMost = currentNode;
1470 if (aHoldSum < aSum)
1473 leftMostHold = leftMost;
1474 leftSibHold = leftSib;
1493 while (!sequence.
empty())
1498 if (sequence.
size() == 1)
1499 leftSib = currentNode;
1501 if (leftSib ==
nullptr)
1502 leftSib = actualNode;
1503 leftMost = currentNode;
1505 if (aHoldSum < aSum)
1508 leftMostHold = leftMost;
1509 leftSibHold = leftSib;
1518 if (actualNode != lastChild)
1520 checkSibling = actualNode->
getNextSib(holdSibling);
1521 holdSibling = actualNode;
1522 actualNode = checkSibling;
1539 if (!sequence.
empty())
1542 while (!sequence.
empty())
1547 if (sequence.
size() == 1)
1548 leftSib = currentNode;
1550 leftMost = currentNode;
1552 if (aHoldSum < aSum)
1555 leftMostHold = leftMost;
1556 leftSibHold = leftSib;
1569 beta2 = sumAllW - aHoldSum;
1586 template<
class T,
class Y>
1612 currentNode = (*it);
1617 if (sumMaxA < sumHelp)
1620 (*aChild) = currentNode;
1626 currentNode = (*it);
1629 if (sumMaxA < sumHelp)
1632 (*aChild) = currentNode;
1635 return sumAllW - sumMaxA;
1638 template<
class T,
class Y>
1653 sum = sum + (*it)->getNodeInfo()->userStructInfo()->m_w;
1655 sum = sum + (*it)->getNodeInfo()->userStructInfo()->m_w;
1660 template<
class T,
class Y>
1663 if (nodePtr->
parent() ==
nullptr)
1666 return nodePtr->
parent();
1681 oldSib = currentNode;
1682 currentNode = nextNode;
1686 return currentNode->
parent();
int setAchildren(PQNode< T, whaInfo *, Y > *hChild2, PQNode< T, whaInfo *, Y > *hChild2Sib)
Traces all children of the largest consecutive sequence of pertinent children of a Q-node...
int pertChildCount() const
Returs the number of pertinent children of a node.
Declaration of class whaInfo.
void findMinWHASequence(ArrayBuffer< PQNode< T, whaInfo *, Y > *> &archiv, SList< PQLeafKey< T, whaInfo *, Y > *> &eliminatedKeys)
Checks the [w,h,a]-number of the pertinent root.
SListPure< PQNode< T, whaInfo *, Y > * > cleanUp
Used to store all pertinent Nodes of the pertinent subtree before removing the minimal pertinent subs...
The parameterized class Queue<E> implements list-based queues.
bool valid() const
Returns true iff the iterator points to an element.
iterator append(const E &x)
Adds x at the end of queue.
bool empty() const
Returns true iff the list is empty.
Nodes that need to be removed in order to obtain a maximal pertinent sequence are marked WhaDelete...
int size() const
Returns the number of elements in the list.
void hNumQnode(PQNode< T, whaInfo *, Y > *nodePtr, int sumAllW)
Computes the h-number of the partial Q-node nodePtr.
void haNumPnode(PQNode< T, whaInfo *, Y > *nodePtr)
Computes the h- and a-number of a P-node nodePtr.
Nodes removed during the template reduction are marked as as Eliminated. Their memory is not freed...
int setHchild(PQNode< T, whaInfo *, Y > *hChild1)
Processes the children of a Q-node, marking a full sequence of children with at most incident partial...
virtual void clientDefinedEmptyNode(PQNode< T, whaInfo *, Y > *nodePtr)
Does a clean up of a node. Called by emptyAllPertinentNodes.
void push(E e)
Puts a new element in the buffer.
Declaration and implementation of the class PQTree.
An array that keeps track of the number of inserted elements; also usable as an efficient stack...
Encapsulates a pointer to an ogdf::SList element.
void haNumQnode(PQNode< T, whaInfo *, Y > *nodePtr)
Computes the h- and a-number of the partial Q-node nodePtr.
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...
PQNode< T, whaInfo *, Y > * m_pertinentRoot
a pointer to the root of the pertinent subtree.
virtual PQNodeMark mark() const =0
mark() returns the variable PQLeaf::m_mark in the derived class PQLeaf and PQInternalNode.
void emptyNode(PQNode< T, whaInfo *, Y > *nodePtr)
Cleans up all stacks, flags and pointers of a pertinent node that has been visited during the reducti...
PQNode< T, whaInfo *, Y > * m_root
a pointer to the root of the $PQ$-tree.
PQNode< T, whaInfo *, Y > * GetParent(PQNode< T, whaInfo *, Y > *nodePtr)
Computes for the node nodePtr its valid parent in the PQ-tree.
Singly linked lists (maintaining the length of the list).
bool valid() const
Returns true iff the iterator points to an element.
virtual PQNodeStatus status() const =0
Returns the variable PQLeaf::m_status in the derived class PQLeaf and PQInternalNode.
List< PQNode< T, whaInfo *, Y > *> * partialChildren(PQNode< T, whaInfo *, Y > *nodePtr)
E popFrontRet()
Removes the first element from the list and returns it.
List< PQNode< T, whaInfo *, Y > *> * m_pertinentNodes
Stores all nodes that have been marked PQNodeRoot::PQNodeStatus::Full or PQNodeRoot::PQNodeStatus::Pa...
PQNode< T, X, Y > * getNextSib(PQNode< T, X, Y > *other) const
The function getNextSib() returns one of the siblings of the node.
void markPertinentChildren(PQNode< T, whaInfo *, Y > *nodePtr, PQNodeRoot::PQNodeStatus label, whaType deleteType)
Marks all full and/or partial children of nodePtr as either an a-, b-, h- or w-node.
virtual void CleanNode(PQNode< T, whaInfo *, Y > *nodePtr)
Frees the memory allocated for the node information class of a node in the PQTree.
virtual void emptyAllPertinentNodes()
Cleans up all flags that have been set in the pertinent nodes during the reduction process...
bool setNodeInfo(PQNodeKey< T, X, Y > *pointerToInfo)
Sets the pointer m_pointerToInfo to the specified adress of pointerToInfo.
bool empty() const
Returns true iff the queue is empty.
PQNodeKey< T, X, Y > * getNodeInfo() const
Returns the identification number of a node.
virtual X userStructInfo()
Returns m_userStructInfo.
Encapsulates a pointer to a list element.
The pertinent Root is marked PertRoot during the clean up after a reduction. Technical.
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
whaType
The definitions for W, B, H and A describe the type of a node during the computation of the maximal p...
SListIterator< E > pushFront(const E &x)
Adds element x at the beginning of the list.
E popFrontRet()
Removes the first element from the list and returns it.
SListPure< PQNode< T, whaInfo *, Y > * > eliminatedNodes
Used to store all eliminated nodes (status == PQNodeRoot::PQNodeStatus::Eliminated) of the PQTree...
PQNode< T, X, Y > * parent() const
The function parent() returns a pointer to the parent of a node.
The class template PQLeafKey is a derived class of class template PQBasicKey.
Includes declaration of graph class.
PQNodeRoot * m_hChild2Sib
int childCount() const
Returns the number of children of a node.
List< PQNode< T, whaInfo *, Y > *> * fullChildren(PQNode< T, whaInfo *, Y > *nodePtr)
PQNode< T, X, Y > * getEndmost(PQNode< T, X, Y > *other) const
Returns one of the endmost children of node, if node is a Q-node.
void setNodePointer(PQNode< T, X, Y > *pqNode)
The function setNodePointer() sets the private member m_nodePointer.
The namespace for all OGDF objects.
The class template MaxSequencePQTree is designed to compute a maximal consecutive sequence of pertine...
int determineMinRemoveSequence(SListPure< PQLeafKey< T, whaInfo *, Y > *> &leafKeys, SList< PQLeafKey< T, whaInfo *, Y > *> &eliminatedKeys)
Computes the maximal pertinent sequence S' of elements of the set S, that can be reduced in a PQ-tree...
int alpha1beta1Number(PQNode< T, whaInfo *, Y > *nodePtr, PQNode< T, whaInfo *, Y > **aChild)
Returns alpha_1 = beta_1 = sum_{i in P(nodePtr)} w_i - max_{i in P(nodePtr)}{(w_i = a_i)}...
E pop()
Removes front element and returns it.
void aNumQnode(PQNode< T, whaInfo *, Y > *nodePtr, int sumAllW)
Computes the a-number of the partial Q-node nodePtr.
Container::value_type sum(const Container &values)
Returns the sum of an iterable container of given values.
virtual bool Bubble(SListPure< PQLeafKey< T, whaInfo *, Y > *> &leafKeys)
The function Bubble() is an overloaded function of the base template class PQTree.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
virtual PQNodeType type() const =0
Returns the variable PQInternalNode::m_type in the derived class PQLeaf and PQInternalNode.
virtual void emptyAllPertinentNodes()
Does a clean up after a reduction.
int sumPertChild(PQNode< T, whaInfo *, Y > *nodePtr)
Returns w = sum_{i in P(nodePtr)}w_i, where nodePtr is any pertinent node of the PQ-tree.