A node in a PC-tree that is either a P-node, C-node or leaf. More...
#include <ogdf/basic/pctree/PCNode.h>
Classes | |
struct | TempInfo |
Temporary information used during each step of the PCTree::makeConsecutive() update operation. More... | |
Public Types | |
using | LeafUserData = std::array< void *, sizeof(TempInfo)/sizeof(void *)> |
Public Member Functions | |
Iterator methods | |
These methods allow easily walking around the PC-tree. | |
PCNode * | getNextSibling (const PCNode *pred) const |
Given the left or right sibling pred , return the adjacent sibling on the other side. More... | |
PCNode * | getOtherOuterChild (const PCNode *child) const |
Given one outer child, return the outer child on the other side. More... | |
PCNode * | getNextNeighbor (const PCNode *pred, const PCNode *curr) const |
Method to walk the cyclic order of all neighbors, i.e., all children plus the parent, where this node's parent is considered to be adjacent to this node's two outer children. More... | |
void | proceedToNextNeighbor (PCNode *&pred, PCNode *&curr) const |
Iteration-convenience version of getNextNeighbor() that updates the variables pred to curr and curr to the value returned by getNextNeighbor(pred, curr). More... | |
PCNode * | getParent () const |
PCNodeChildrenIterable | children () |
PCNodeNeighborsIterable | neighbors (PCNode *first=nullptr) |
Structure check methods | |
These methods help with checking the current status of this node w.r.t. its surrounding tree structure. | |
bool | isDetached () const |
bool | isValidNode (const PCTreeForest *ofForest=nullptr) const |
Perform multiple debug checks and return true if getForest == ofForest . More... | |
bool | isLeaf () const |
bool | isParentOf (const PCNode *other) const |
bool | isSiblingOf (const PCNode *other) const |
bool | isSiblingAdjacent (const PCNode *sibling) const |
bool | areNeighborsAdjacent (const PCNode *neigh1, const PCNode *neigh2) const |
bool | isChildOuter (const PCNode *child) const |
bool | isOuterChild () const |
Getters | |
size_t | index () const |
PCNodeType | getNodeType () const |
size_t | getChildCount () const |
size_t | getDegree () const |
PCNode * | getChild1 () const |
PCNode * | getChild2 () const |
PCNode * | getOnlyChild () const |
Check whether this node has only one child and return it. More... | |
PCNode * | getSibling1 () const |
PCNode * | getSibling2 () const |
PCTreeForest * | getForest () const |
Private Member Functions | |
PCNode (PCTreeForest *forest, size_t id, PCNodeType nodeType) | |
~PCNode () | |
Private Attributes | |
union { | |
TempInfo m_temp | |
LeafUserData m_userData | |
}; | |
PCNode * | m_child1 = nullptr |
PCNode * | m_child2 = nullptr |
size_t | m_childCount = 0 |
PCTreeForest * | m_forest |
size_t | m_id |
NodeLabel | m_label = NodeLabel::Unknown |
UnionFindIndex | m_nodeListIndex = UNIONFINDINDEX_EMPTY |
PCNodeType | m_nodeType |
UnionFindIndex | m_parentCNodeId = UNIONFINDINDEX_EMPTY |
PCNode * | m_parentPNode = nullptr |
PCNode * | m_sibling1 = nullptr |
PCNode * | m_sibling2 = nullptr |
size_t | m_timestamp = 0 |
Friends | |
std::ostream & | operator<<) (std::ostream &, const ogdf::pc_tree::PCNode *) |
std::ostream & | operator<<) (std::ostream &, const ogdf::pc_tree::PCTree *) |
struct | PCNodeChildrenIterable |
struct | PCNodeNeighborsIterable |
class | PCTree |
class | PCTreeForest |
Tree structure methods | |
These methods allow modifying the tree structure or embedding, e.g., when manually constructing a PC-tree. | |
void | replaceSibling (PCNode *oldS, PCNode *newS) |
Notify this node that one of its adjacent siblings changed. More... | |
void | rotateChildOutside (bool child1=true) |
Make this node an outer child of its parent. More... | |
void | replaceOuterChild (PCNode *oldC, PCNode *newC) |
Notify this node that one of its outer children was replaced. More... | |
void | setParent (PCNode *parent) |
Notify this node that it has a new parent. More... | |
void | forceDetach () |
detach() without performing checks. More... | |
void | changeType (PCNodeType newType) |
Overwrite the type of this node without updating any other data structures. More... | |
void | appendChild (PCNode *child, bool begin=false) |
Append a (detached) child node to the begin or end of this nodes' children. More... | |
void | insertBetween (PCNode *sib1, PCNode *sib2) |
Insert a (detached) child node directly between two adjacent children of this node. More... | |
void | detach () |
Detach this node from its parent. More... | |
void | replaceWith (PCNode *repl) |
Swaps this node inplace with a (detached) other one. More... | |
void | mergeIntoParent () |
Merges this C-node into its C-node parent. More... | |
void | flip () |
Reverse the stored order of children. More... | |
makeConsecutive-related temporary information | |
These methods provide access to temporary information used during a PCTree::makeConsecutive() call. | |
NodeLabel | getLabelUnchecked () const |
void | setLabelUnchecked (NodeLabel l) |
void | checkTimestamp () const |
TempInfo & | tempInfo () |
size_t | addFullNeighbor (PCNode *fullNeigh) |
PCNode *& | getFullNeighInsertionPoint (PCNode *nonFullNeigh) |
const TempInfo & | constTempInfo () const |
bool | isFull () const |
NodeLabel | getLabel () const |
void | setLabel (NodeLabel l) |
LeafUserData & | leafUserData () |
const LeafUserData & | leafUserData () const |
A node in a PC-tree that is either a P-node, C-node or leaf.
See https://doi.org/10.15475/cpatp.2024 Figure 8.3 for a visualization of the doubly-linked tree structure stored in each node and more details on the changes made and temporary information stored by PCTree::makeConsecutive(). Important terminology:
using ogdf::pc_tree::PCNode::LeafUserData = std::array<void*, sizeof(TempInfo) / sizeof(void*)> |
|
inlineprivate |
|
inlineprivate |
void ogdf::pc_tree::PCNode::appendChild | ( | PCNode * | child, |
bool | begin = false |
||
) |
Append a (detached) child node to the begin or end of this nodes' children.
bool ogdf::pc_tree::PCNode::areNeighborsAdjacent | ( | const PCNode * | neigh1, |
const PCNode * | neigh2 | ||
) | const |
true
if neigh1 and neigh2 are children of this node and isSiblingAdjacent(neigh1, neigh2) is true, or if one of the passed nodes is the parent of this node and the other one is an outer child of this node
|
inlineprivate |
|
private |
PCNodeChildrenIterable ogdf::pc_tree::PCNode::children | ( | ) |
|
inline |
void ogdf::pc_tree::PCNode::detach | ( | ) |
Detach this node from its parent.
Invalidates but does not change the PC-forest of the node, so don't forget to re-attach it somewhere else in a PC-tree of the same forest to make it valid again.
|
inline |
|
private |
detach() without performing checks.
|
inline |
|
inline |
|
inlineprivate |
Method to walk the cyclic order of all neighbors, i.e., all children plus the parent, where this node's parent is considered to be adjacent to this node's two outer children.
The returned node is the one of the two nodes adjacent to curr
in this cyclic order that is not pred
, or an arbitrary one of the two if pred
is null.
Given the left or right sibling pred
, return the adjacent sibling on the other side.
|
inline |
|
inline |
Given one outer child, return the outer child on the other side.
PCNode* ogdf::pc_tree::PCNode::getParent | ( | ) | const |
|
inline |
|
inline |
Insert a (detached) child node directly between two adjacent children of this node.
|
inline |
true
, if child
is an outer child of this node, i.e., if this->getChild1() == child or this->getChild2() == child
|
inline |
|
inline |
true
, if this node is an outer child of its parent, i.e., if this->getSibling1() == nullptr or this->getSibling2() == child
|
inline |
true
, if other->getParent() == this
|
inline |
true
, if this->getSibling1() == sibling or this->getSibling2() == sibling
|
inline |
true
, if this->getParent() == other->getParent() bool ogdf::pc_tree::PCNode::isValidNode | ( | const PCTreeForest * | ofForest = nullptr | ) | const |
Perform multiple debug checks and return true
if getForest == ofForest
.
|
inline |
|
inline |
void ogdf::pc_tree::PCNode::mergeIntoParent | ( | ) |
Merges this C-node into its C-node parent.
PCNodeNeighborsIterable ogdf::pc_tree::PCNode::neighbors | ( | PCNode * | first = nullptr | ) |
Iteration-convenience version of getNextNeighbor() that updates the variables pred
to curr
and curr
to the value returned by getNextNeighbor(pred, curr).
Notify this node that one of its outer children was replaced.
Notify this node that one of its adjacent siblings changed.
void ogdf::pc_tree::PCNode::replaceWith | ( | PCNode * | repl | ) |
Swaps this node inplace with a (detached) other one.
Afterwards, this node will be detached.
|
private |
Make this node an outer child of its parent.
Only works for children of the root node.
|
inlineprivate |
|
private |
Notify this node that it has a new parent.
|
inlineprivate |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
union { ... } |
|
private |
|
mutableprivate |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
mutableprivate |
LeafUserData ogdf::pc_tree::PCNode::m_userData |