|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
49 template<
class T,
class X,
class Y>
103 template<
class T,
class Y>
392 template<
class T,
class Y>
406 for (it = leafKeys.begin(); it.
valid(); ++it) {
408 processNodes.
append(checkLeaf);
409 cleanUp.pushBack(checkLeaf);
414 infoPtr->setNodePointer(checkLeaf);
429 while (!processNodes.
empty()) {
431 nodePtr->
parent(GetParent(nodePtr));
440 infoPtr->setNodePointer(nodePtr->
parent());
442 if (nodePtr != this->m_root) {
445 cleanUp.pushBack(nodePtr->
parent());
468 for (itn = cleanUp.begin(); itn.
valid(); ++itn) {
475 template<
class T,
class Y>
483 template<
class T,
class Y>
497 template<
class T,
class Y>
501 while (!cleanUp.empty()) {
502 nodePtr = cleanUp.popFrontRet();
520 for (it = this->m_pertinentNodes->begin(); it.
valid(); ++it) {
524 eliminatedNodes.pushBack(nodePtr);
536 template<
class T,
class Y>
543 int countDeletedLeaves = 0;
545 int maxPertLeafCount = 0;
562 for (it = leafKeys.begin(); it.
valid(); ++it) {
566 processNodes.
append(checkLeaf);
567 archiv.
push(checkLeaf);
572 while (!processNodes.
empty()) {
573 nodePtr = processNodes.
pop();
601 fullChildren(nodePtr->
parent())->pushFront(nodePtr);
609 if (fullChildren(nodePtr)->size() == nodePtr->
childCount()) {
615 fullChildren(nodePtr->
parent())->pushFront(nodePtr);
627 partialChildren(nodePtr->
parent())->pushFront(nodePtr);
645 this->m_pertinentRoot = nodePtr;
646 if (this->m_pertinentRoot->getNodeInfo()->userStructInfo()->m_h
647 < this->m_pertinentRoot->getNodeInfo()->userStructInfo()->m_a) {
650 countDeletedLeaves = this->m_pertinentRoot->getNodeInfo()->userStructInfo()->m_a;
653 if (countDeletedLeaves > 0) {
654 if (this->m_pertinentRoot->getNodeInfo()->userStructInfo()->m_h
655 < this->m_pertinentRoot->getNodeInfo()->userStructInfo()->m_a) {
656 this->m_pertinentRoot->getNodeInfo()->userStructInfo()->m_deleteType =
whaType::H;
658 this->m_pertinentRoot->getNodeInfo()->userStructInfo()->m_deleteType =
whaType::A;
662 findMinWHASequence(archiv, eliminatedKeys);
664 return countDeletedLeaves;
667 template<
class T,
class Y>
682 while (!archiv.empty()) {
699 this->m_pertinentNodes->pushFront(nodePtr);
709 eliminatedKeys.pushBack(nodePtr->
getKey());
711 this->m_pertinentNodes->pushFront(nodePtr);
723 this->m_pertinentNodes->pushFront(nodePtr);
729 this->m_pertinentNodes->pushFront(nodePtr);
754 - partialChildren(nodePtr)->size());
769 this->m_pertinentNodes->pushFront(nodePtr);
827 - partialChildren(nodePtr)->size());
870 this->m_pertinentNodes->pushFront(nodePtr);
880 fullChildren(nodePtr)->clear();
881 partialChildren(nodePtr)->clear();
893 template<
class T,
class Y>
896 int pertinentChildCount = 0;
899 bool fullLabel =
false;
905 if (hChild1 !=
nullptr) {
922 nextSibling = currentNode->
getNextSib(oldSibling);
929 pertinentChildCount++;
938 pertinentChildCount++;
943 oldSibling = currentNode;
944 currentNode = nextSibling;
947 return pertinentChildCount;
950 template<
class T,
class Y>
963 int pertinentChildCount = 0;
981 pertinentChildCount++;
987 nextSibling = hChild2Sib;
988 oldSibling = hChild2;
990 if (nextSibling !=
nullptr) {
991 currentNode = nextSibling;
994 bool reachedEnd =
false;
996 while (!reachedEnd) {
999 pertinentChildCount++;
1006 pertinentChildCount++;
1012 nextSibling = currentNode->
getNextSib(oldSibling);
1013 if (nextSibling ==
nullptr) {
1016 oldSibling = currentNode;
1017 currentNode = nextSibling;
1022 return pertinentChildCount;
1025 template<
class T,
class Y>
1038 for (it = partialChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1039 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1041 for (it = fullChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1042 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1046 for (it = partialChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1047 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1053 for (it = fullChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1054 (*it)->getNodeInfo()->userStructInfo()->m_deleteType = deleteType;
1059 template<
class T,
class Y>
1100 for (it = partialChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1101 currentNode = (*it);
1105 if (sumMax1 <= sumHelp) {
1109 hChild1 = currentNode;
1110 }
else if (sumMax2 <= sumHelp) {
1112 hChild2 = currentNode;
1135 int alpha2 = sumParW - sumMax1 - sumMax2;
1136 int alpha1 = alpha1beta1Number(nodePtr, &aChild);
1138 if (alpha1 <= alpha2) {
1147 template<
class T,
class Y>
1153 int sumAllW = sumPertChild(nodePtr);
1155 hNumQnode(nodePtr, sumAllW);
1156 aNumQnode(nodePtr, sumAllW);
1159 template<
class T,
class Y>
1184 bool fullLabel =
true;
1218 checkSibling = leftChild->
getNextSib(holdSibling);
1219 if (checkSibling ==
nullptr) {
1222 holdSibling = leftChild;
1223 leftChild = checkSibling;
1240 holdSibling =
nullptr;
1241 checkSibling =
nullptr;
1251 checkSibling = rightChild->
getNextSib(holdSibling);
1253 if (checkSibling ==
nullptr) {
1257 holdSibling = rightChild;
1258 rightChild = checkSibling;
1272 if (sumLeft == 0 && sumRight == 0) {
1275 }
else if (sumLeft < sumRight) {
1284 template<
class T,
class Y>
1312 int beta1 = alpha1beta1Number(nodePtr, &aChild);
1316 bool endReached = 0;
1334 while (!endReached) {
1342 if (sequence.
empty()) {
1390 while (!sequence.
empty()) {
1394 if (sequence.
size() == 1) {
1395 leftSib = currentNode;
1398 leftMost = currentNode;
1400 if (aHoldSum < aSum) {
1402 leftMostHold = leftMost;
1403 leftSibHold = leftSib;
1420 while (!sequence.
empty()) {
1424 if (sequence.
size() == 1) {
1425 leftSib = currentNode;
1428 if (leftSib ==
nullptr) {
1429 leftSib = actualNode;
1431 leftMost = currentNode;
1433 if (aHoldSum < aSum) {
1435 leftMostHold = leftMost;
1436 leftSibHold = leftSib;
1444 if (actualNode != lastChild) {
1445 checkSibling = actualNode->
getNextSib(holdSibling);
1446 holdSibling = actualNode;
1447 actualNode = checkSibling;
1464 if (!sequence.
empty()) {
1466 while (!sequence.
empty()) {
1470 if (sequence.
size() == 1) {
1471 leftSib = currentNode;
1474 leftMost = currentNode;
1476 if (aHoldSum < aSum) {
1478 leftMostHold = leftMost;
1479 leftSibHold = leftSib;
1492 beta2 = sumAllW - aHoldSum;
1493 if (beta2 < beta1) {
1506 template<
class T,
class Y>
1528 for (it = fullChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1529 currentNode = (*it);
1533 if (sumMaxA < sumHelp) {
1535 (*aChild) = currentNode;
1539 for (it = partialChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1540 currentNode = (*it);
1544 if (sumMaxA < sumHelp) {
1546 (*aChild) = currentNode;
1549 return sumAllW - sumMaxA;
1552 template<
class T,
class Y>
1565 for (it = fullChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1566 sum = sum + (*it)->getNodeInfo()->userStructInfo()->m_w;
1568 for (it = partialChildren(nodePtr)->
begin(); it.
valid(); ++it) {
1569 sum = sum + (*it)->getNodeInfo()->userStructInfo()->m_w;
1575 template<
class T,
class Y>
1577 if (nodePtr->
parent() ==
nullptr) {
1580 return nodePtr->
parent();
1593 oldSib = currentNode;
1594 currentNode = nextNode;
1596 while (!L.
empty()) {
1599 return currentNode->
parent();
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
The namespace for all OGDF objects.
PQNode< T, whaInfo *, Y > * GetParent(PQNode< T, whaInfo *, Y > *nodePtr)
Computes for the node nodePtr its valid parent in the PQ-tree.
Declaration and implementation of ArrayBuffer class.
iterator append(const E &x)
Adds x at the end of queue.
Declaration and implementation of the class PQNode.
void haNumQnode(PQNode< T, whaInfo *, Y > *nodePtr)
Computes the h- and a-number of the partial Q-node nodePtr.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
The class template PQLeafKey is a derived class of class template PQBasicKey.
Encapsulates a pointer to an ogdf::SList element.
@ WhaDelete
Nodes that need to be removed in order to obtain a maximal pertinent sequence are marked WhaDelete.
bool setNodeInfo(PQNodeKey< T, X, Y > *pointerToInfo)
Sets the pointer m_pointerToInfo to the specified adress of pointerToInfo.
Singly linked lists (maintaining the length of the list).
E popFrontRet()
Removes the first element from the list and returns it.
bool valid() const
Returns true iff the iterator points to an element.
Declaration and implementation of list-based queues (classes QueuePure<E> and Queue<E>).
virtual PQNodeMark mark() const =0
mark() returns the variable PQLeaf::m_mark in the derived class PQLeaf and PQInternalNode.
void findMinWHASequence(ArrayBuffer< PQNode< T, whaInfo *, Y > * > &archiv, SList< PQLeafKey< T, whaInfo *, Y > * > &eliminatedKeys)
Checks the [w,h,a]-number of the pertinent root.
Declaration and implementation of the class PQNodeRoot.
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.
bool valid() const
Returns true iff the iterator points to an element.
Declaration and implementation of the class PQTree.
SListPure< PQNode< T, whaInfo *, Y > * > eliminatedNodes
Used to store all eliminated nodes (status == PQNodeRoot::PQNodeStatus::Eliminated) of the PQTree.
void haNumPnode(PQNode< T, whaInfo *, Y > *nodePtr)
Computes the h- and a-number of a P-node nodePtr.
virtual void emptyAllPertinentNodes()
Cleans up all flags that have been set in the pertinent nodes during the reduction process.
virtual bool Bubble(SListPure< PQLeafKey< T, whaInfo *, Y > * > &leafKeys)
The function Bubble() is an overloaded function of the base template class PQTree.
bool empty() const
Returns true iff the list is empty.
whaType
The definitions for W, B, H and A describe the type of a node during the computation of the maximal p...
Declaration and implementation of the class PQNodeKey.
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...
int pertChildCount() const
Returs the number of pertinent children of a node.
E pop()
Removes front element and returns it.
int size() const
Returns the number of elements in the list.
Declaration of singly linked lists and iterators.
virtual X userStructInfo()
Returns m_userStructInfo.
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.
void aNumQnode(PQNode< T, whaInfo *, Y > *nodePtr, int sumAllW)
Computes the a-number of the partial Q-node 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.
The parameterized class Queue<E> implements list-based queues.
SListIterator< E > pushFront(const E &x)
Adds element x at the beginning of the list.
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...
virtual PQNodeType type() const =0
Returns the variable PQInternalNode::m_type in the derived class PQLeaf and PQInternalNode.
Declaration of class whaInfo.
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.
virtual void clientDefinedEmptyNode(PQNode< T, whaInfo *, Y > *nodePtr)
Does a clean up of a node. Called by emptyAllPertinentNodes.
bool empty() const
Returns true iff the queue is empty.
E popFrontRet()
Removes the first element from the list and returns it.
@ Eliminated
Nodes removed during the template reduction are marked as as Eliminated. Their memory is not freed....
PQNodeKey< T, X, Y > * getNodeInfo() const
Returns the identification number of a node.
The class template MaxSequencePQTree is designed to compute a maximal consecutive sequence of pertine...
Basic declarations, included by all source files.
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)},...
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.
Declaration of doubly linked lists and iterators.
PQNodeRoot * m_hChild2Sib
SListPure< PQNode< T, whaInfo *, Y > * > cleanUp
Used to store all pertinent Nodes of the pertinent subtree before removing the minimal pertinent subs...
Encapsulates a pointer to a list element.
iterator pushFront(const E &x)
Adds element x at the beginning of the list.
int childCount() const
Returns the number of children of a node.
virtual void CleanNode(PQNode< T, whaInfo *, Y > *nodePtr)
Frees the memory allocated for the node information class of a node in the PQTree.
void hNumQnode(PQNode< T, whaInfo *, Y > *nodePtr, int sumAllW)
Computes the h-number of the partial Q-node nodePtr.
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...
PQNode< T, X, Y > * parent() const
The function parent() returns a pointer to the parent of a node.
virtual void emptyAllPertinentNodes()
Does a clean up after a reduction.
@ PertRoot
The pertinent Root is marked PertRoot during the clean up after a reduction. Technical.