49struct PCNodeChildrenIterable;
50struct PCNodeNeighborsIterable;
76 PCNode *predPartial =
nullptr, *nextPartial =
nullptr;
79 size_t tpPartialHeight = 0;
82 PCNode *ebEnd1 =
nullptr, *fbEnd1 =
nullptr, *fbEnd2 =
nullptr, *ebEnd2 =
nullptr;
85 if (tpPred == oldNeigh) {
88 if (tpPartialPred == oldNeigh) {
89 tpPartialPred = newNeigh;
91 if (tpSucc == oldNeigh) {
94 if (ebEnd1 == oldNeigh) {
97 if (ebEnd2 == oldNeigh) {
100 if (fbEnd1 == oldNeigh) {
103 if (fbEnd2 == oldNeigh) {
109 nextPartial = predPartial =
nullptr;
110 tpPred = tpPartialPred = tpSucc =
nullptr;
111 ebEnd1 = fbEnd1 = fbEnd2 = ebEnd2 =
nullptr;
113 fullNeighbors.clear();
135 size_t m_childCount = 0;
137 mutable size_t m_timestamp = 0;
155 if (m_nodeType == PCNodeType::Leaf) {
197 void flip() { std::swap(m_child1, m_child2); }
229 if (m_nodeType == PCNodeType::Leaf && newType != PCNodeType::Leaf) {
232 }
else if (m_nodeType != PCNodeType::Leaf && newType == PCNodeType::Leaf) {
236 m_nodeType = newType;
310 bool isLeaf()
const {
return m_nodeType == PCNodeType::Leaf; }
327 return this->getParent() == other->
getParent();
336 return m_sibling1 == sibling || m_sibling2 == sibling;
350 return m_child1 == child || m_child2 == child;
356 bool isOuterChild()
const {
return m_sibling1 ==
nullptr || m_sibling2 ==
nullptr; }
373 bool isFull()
const {
return getLabel() == NodeLabel::Full; }
377 return m_forest->
m_timestamp == m_timestamp ? m_label : NodeLabel::Empty;
427 m_temp.fullNeighbors.push_back(fullNeigh);
428 return m_temp.fullNeighbors.size();
435 if (nonFullNeigh == m_temp.ebEnd1) {
436 OGDF_ASSERT(areNeighborsAdjacent(m_temp.ebEnd1, m_temp.fbEnd1));
437 return m_temp.fbEnd1;
440 OGDF_ASSERT(areNeighborsAdjacent(m_temp.ebEnd2, m_temp.fbEnd2));
441 return m_temp.fbEnd2;
452 size_t index()
const {
return m_id; }
458 size_t getDegree()
const {
return isDetached() ? m_childCount : m_childCount + 1; }
An intrusive list for the leaves of a PCTree.
Predeclaration of various PC-tree related classes and enums.
PCTreeForests contain multiple PCTrees that can be merged with each other.
Basic declarations, included by all source files.
Class for the representation of nodes.
A node in a PC-tree that is either a P-node, C-node or leaf.
PCNode(PCTreeForest *forest, size_t id, PCNodeType nodeType)
void rotateChildOutside(bool child1=true)
Make this node an outer child of its parent.
void checkTimestamp() const
void mergeIntoParent()
Merges this C-node into its C-node parent.
bool areNeighborsAdjacent(const PCNode *neigh1, const PCNode *neigh2) const
PCNode *& getFullNeighInsertionPoint(PCNode *nonFullNeigh)
void replaceOuterChild(PCNode *oldC, PCNode *newC)
Notify this node that one of its outer children was replaced.
PCNodeNeighborsIterable neighbors(PCNode *first=nullptr)
void setLabel(NodeLabel l)
PCTreeForest * getForest() const
bool isValidNode(const PCTreeForest *ofForest=nullptr) const
Perform multiple debug checks and return true if getForest == ofForest.
bool isSiblingAdjacent(const PCNode *sibling) const
void flip()
Reverse the stored order of children.
void replaceSibling(PCNode *oldS, PCNode *newS)
Notify this node that one of its adjacent siblings changed.
PCNode * getOnlyChild() const
Check whether this node has only one child and return it.
bool isSiblingOf(const PCNode *other) const
void detach()
Detach this node from its parent.
LeafUserData & leafUserData()
void setLabelUnchecked(NodeLabel l)
void forceDetach()
detach() without performing checks.
void setParent(PCNode *parent)
Notify this node that it has a new parent.
PCNode * getOtherOuterChild(const PCNode *child) const
Given one outer child, return the outer child on the other side.
friend std::ostream & operator<<)(std::ostream &, const ogdf::pc_tree::PCNode *)
const LeafUserData & leafUserData() const
const TempInfo & constTempInfo() const
void appendChild(PCNode *child, bool begin=false)
Append a (detached) child node to the begin or end of this nodes' children.
PCNode * getParent() const
friend std::ostream & operator<<)(std::ostream &, const ogdf::pc_tree::PCTree *)
PCNode * getChild1() const
PCNode * getNextSibling(const PCNode *pred) const
Given the left or right sibling pred, return the adjacent sibling on the other side.
void changeType(PCNodeType newType)
Overwrite the type of this node without updating any other data structures.
bool isOuterChild() const
PCNodeChildrenIterable children()
bool isChildOuter(const PCNode *child) const
NodeLabel getLabel() const
PCNode * getChild2() const
PCNode * getSibling1() const
NodeLabel getLabelUnchecked() const
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,...
std::array< void *, sizeof(TempInfo)/sizeof(void *)> LeafUserData
bool isParentOf(const PCNode *other) const
void proceedToNextNeighbor(PCNode *&pred, PCNode *&curr) const
Iteration-convenience version of getNextNeighbor() that updates the variables pred to curr and curr t...
size_t getChildCount() const
void replaceWith(PCNode *repl)
Swaps this node inplace with a (detached) other one.
void insertBetween(PCNode *sib1, PCNode *sib2)
Insert a (detached) child node directly between two adjacent children of this node.
PCNodeType getNodeType() const
PCNode * getSibling2() const
size_t addFullNeighbor(PCNode *fullNeigh)
Multiple PCTrees can be created within the same PCTreeForest, which allows merging the trees later on...
A PC-tree represents a set of cyclic orders of its leaves by labeling its inner nodes as either P- or...
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
NodeElement * node
The type of nodes.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Declaration of memory manager for allocating small pieces of memory.
void proceedToNextSibling(PCNode *&pred, PCNode *&curr)
Iteration-convenience version of PCNode::getNextSibling() that updates the variables pred to curr and...
const UnionFindIndex UNIONFINDINDEX_EMPTY
Temporary information used during each step of the PCTree::makeConsecutive() update operation.
void replaceNeighbor(PCNode *oldNeigh, PCNode *newNeigh)
std::vector< PCNode * > fullNeighbors