Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
PCTree.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/basic.h>
36#include <ogdf/basic/internal/config_autogen.h>
43
44#include <cstddef>
45#include <functional>
46#include <initializer_list>
47#include <iterator>
48#include <list>
49#include <sstream>
50#include <string>
51#include <vector>
52
53namespace ogdf {
54class GraphAttributes;
55} // namespace ogdf
56
57namespace ogdf::pc_tree {
62OGDF_EXPORT bool isTrivialRestriction(int restSize, int leafCount);
63
65
66#ifdef OGDF_DEBUG
75#endif
76
80namespace uid_utils {
84OGDF_EXPORT void nodeToID(std::ostream& os, PCNode* n, int pos);
85
89OGDF_EXPORT void nodeToPosition(std::ostream& os, PCNode* n, int pos);
90
94OGDF_EXPORT void leafToID(std::ostream& os, PCNode* n, int pos);
95
99OGDF_EXPORT void leafToPosition(std::ostream& os, PCNode* n, int pos);
100
105}
106
119 friend OGDF_EXPORT std::ostream&(operator<<)(std::ostream&, const ogdf::pc_tree::PCTree*);
120 friend OGDF_EXPORT std::ostream&(operator<<)(std::ostream&, const ogdf::pc_tree::PCNode*);
121
122 friend class PCNode;
123 friend class PCTreeRegistry;
124 friend class PCTreeForest;
125
126public:
127 struct Observer; // pre-declaration
128
129private:
130 // global
131 PCTreeForest* m_forest = nullptr;
132
133 // needs merge when trees merge
134 size_t m_pNodeCount = 0;
135 size_t m_cNodeCount = 0;
137
138 // needs special merge
139 PCNode* m_rootNode = nullptr;
140
141 // temp makeConsecutive variables
142 size_t m_partialCount = 0;
143 size_t m_terminalPathLength = 0;
144 PCNode* m_firstPartial = nullptr;
145 PCNode* m_lastPartial = nullptr;
146 PCNode* m_apexCandidate = nullptr;
147 bool m_apexCandidateIsFix = false;
148 PCNode* m_apexTPPred2 = nullptr;
149
150 // private
151 bool m_externalForest = true;
152 std::list<Observer*> m_observers;
153
154public:
159 explicit PCTree() : PCTree(nullptr) {};
160
164 explicit PCTree(PCTreeForest* forest) {
165 if (forest) {
166 m_forest = forest;
167 m_externalForest = true;
168 } else {
169 m_forest = new PCTreeForest();
170 m_externalForest = false;
171 }
172 };
173
178 explicit PCTree(int leafNum, std::vector<PCNode*>* added = nullptr,
179 PCTreeForest* forest = nullptr);
180
188 explicit PCTree(const PCTree& other, PCTreeNodeArray<PCNode*>& nodeMapping,
189 bool keep_ids = false, PCTreeForest* forest = nullptr);
190
195 explicit PCTree(const std::string& str, bool keep_ids = false, PCTreeForest* forest = nullptr);
196
197 virtual ~PCTree();
198
199public:
204
212 PCNode* newNode(PCNodeType type, PCNode* parent = nullptr, int id = -1);
213
219 destroyNode((PCNode* const&)node);
220 node = nullptr;
221 }
222
227 void destroyNode(PCNode* const& node);
228
232 void insertLeaves(int count, PCNode* parent, std::vector<PCNode*>* added = nullptr);
233
237 void replaceLeaf(int leafCount, PCNode* leaf, std::vector<PCNode*>* added = nullptr);
238
246 PCNode* mergeLeaves(const std::vector<PCNode*>& consecutiveLeaves,
247 bool assumeConsecutive = false) {
248 return mergeLeaves(consecutiveLeaves.begin(), consecutiveLeaves.end(), assumeConsecutive);
249 }
250
258 template<typename It>
259 PCNode* mergeLeaves(It begin, It end, bool assumeConsecutive = false) {
261
262 if (!assumeConsecutive && !makeConsecutive(begin, end)) {
263 return nullptr;
264 }
265
266 // Remove all consecutive leaves except the first one.
267 It back = prev(end);
268 for (auto it = begin; it != back; ++it) {
269 destroyLeaf(*it);
270 }
271
272 OGDF_HEAVY_ASSERT(checkValid());
273
274 // Return the remaining leaf.
275 return *back;
276 }
277
284 void destroyLeaf(PCNode* leaf);
285
294
302
308
315 void insertTree(PCNode* at, PCTree* tree);
316
317private:
319
321
323
324public:
329
334 bool isTrivialRestriction(int size) const;
335
336 bool makeConsecutive(std::initializer_list<PCNode*> consecutiveLeaves) {
337 return makeConsecutive(consecutiveLeaves.begin(), consecutiveLeaves.end());
338 }
339
340 bool makeConsecutive(const std::vector<PCNode*>& consecutiveLeaves) {
341 return makeConsecutive(consecutiveLeaves.begin(), consecutiveLeaves.end());
342 }
343
351 template<typename It>
352 bool makeConsecutive(It begin, It end) {
353 FullLeafIter iter = [&begin, &end]() { return NextFullLeaf<It>(begin, end); };
354 for (auto obs : m_observers) {
355 obs->makeConsecutiveCalled(*this, iter);
356 }
357
358 OGDF_HEAVY_ASSERT(checkValid());
359 resetTempData();
360
361#ifdef OGDF_DEBUG
362 for (auto it = begin; it != end; ++it) {
363 PCNode* leaf = *it;
364 OGDF_ASSERT(leaf);
365 OGDF_ASSERT(leaf->isLeaf());
366 OGDF_ASSERT(leaf->m_forest == m_forest);
367 }
368#endif
370 for (auto obs : m_observers) {
371 obs->makeConsecutiveDone(*this, Observer::Stage::Trivial, true);
372 }
373 return true;
374 }
375
376 // PC_PROFILE_ENTER(1, "label");
377 markFull(begin, end);
378 // PC_PROFILE_EXIT(1, "label");
379
380 return makeFullNodesConsecutive();
381 }
382
387 m_forest->m_timestamp++;
388 m_firstPartial = m_lastPartial = nullptr;
389 m_partialCount = 0;
390 m_apexCandidate = nullptr;
391 m_apexCandidateIsFix = false;
392 m_terminalPathLength = 0;
393 m_apexTPPred2 = nullptr;
394 }
395
400 template<typename It>
401 void markLeavesFull(It begin, It end) {
402 for (auto it = begin; it != end; ++it) {
403 PCNode* leaf = *it;
404 OGDF_ASSERT(leaf);
405 OGDF_ASSERT(leaf->isLeaf());
406 OGDF_ASSERT(leaf->m_forest == m_forest);
407 leaf->setLabel(NodeLabel::Full);
408 }
409 }
410
416 template<typename It>
417 void markFull(It begin, It end, std::vector<PCNode*>* fullNodeOrder = nullptr) {
418 // Attention: This method no longer uses a queue to defer processing of partial/full parents to after
419 // all leaves are done, but now directly make parents full if all of their children are full.
420 if (fullNodeOrder != nullptr) {
421 fullNodeOrder->reserve(m_cNodeCount + m_pNodeCount);
422 }
423
424 for (auto it = begin; it != end; ++it) {
425 PCNode* full_parent = markFull(*it, fullNodeOrder);
426 while (full_parent != nullptr) {
427 full_parent = markFull(full_parent, fullNodeOrder);
428 }
429 }
430 }
431
439
440private:
441 /* see the paper for more info on how the update works with the following methods */
442
443 PCNode* markFull(PCNode* full_node, std::vector<PCNode*>* fullNodeOrder = nullptr);
444
446
448
450
451 int updateTerminalPath(PCNode* central, PCNode* tpNeigh);
452
453 // labeling / TP finding
454
455 void addPartialNode(PCNode* partial);
456
457 void removePartialNode(PCNode* partial);
458
460
461 size_t findEndOfFullBlock(PCNode* node, PCNode* pred, PCNode* curr, PCNode*& fullEnd,
462 PCNode*& emptyEnd) const;
463
464 bool setApexCandidate(PCNode* ac, bool fix = false);
465
466 // update
467
468 void replaceTPNeigh(PCNode* central, PCNode* oldTPNeigh, PCNode* newTPNeigh,
469 PCNode* newFullNeigh, PCNode* otherEndOfFullBlock);
470
471 PCNode* splitOffFullPNode(PCNode* node, bool skip_parent);
472
474
475public:
480
487
488private:
490 PCTreeNodeArray<std::vector<PCNode*>>& blockNodes,
491 PCTreeNodeArray<std::vector<PCNode*>>& subtreeNodes,
492 PCTreeNodeArray<PCNode*>& leafPartner, PCTreeNodeArray<bool>& isFront);
493
494 void restoreSubtrees(PCTreeNodeArray<std::vector<PCNode*>>& blockNodes,
495 PCTreeNodeArray<std::vector<PCNode*>>& subtreeNodes,
496 PCTreeNodeArray<PCNode*>& leafPartner, PCTreeNodeArray<bool>& isFront);
497
499
500public:
505 operator const PCTreeRegistry&() const { return m_forest->m_nodeArrayRegistry; }
506
508 [[nodiscard]] PCTreeForest* getForest() const { return m_forest; }
509
511 [[nodiscard]] bool isTrivial() const;
512
513 [[nodiscard]] const IntrusiveList<PCNode>& getLeaves() const { return m_leaves; }
514
515 [[nodiscard]] size_t getLeafCount() const { return m_leaves.size(); };
516
517 [[nodiscard]] size_t getPNodeCount() const { return m_pNodeCount; }
518
519 [[nodiscard]] size_t getCNodeCount() const { return m_cNodeCount; }
520
521 [[nodiscard]] PCNode* getRootNode() const { return m_rootNode; }
522
526 int getTerminalPathLength() const { return m_terminalPathLength; }
527
529 FilteringPCTreeDFS allNodes() const { return FilteringPCTreeDFS(*this, m_rootNode); }
530
533 return FilteringPCTreeDFS(*this, m_rootNode, [](PCNode* node) { return !node->isLeaf(); });
534 }
535
537 template<typename Container>
538 void currentLeafOrder(Container& container) const {
539 for (PCNode* leaf : FilteringPCTreeDFS(*this, m_rootNode)) {
540 if (leaf->isLeaf()) {
541 container.push_back(leaf);
542 }
543 }
544 OGDF_ASSERT(container.size() == m_leaves.size());
545 }
546
547 std::vector<PCNode*> currentLeafOrder() const {
548 std::vector<PCNode*> container;
549 currentLeafOrder(container);
550 return container;
551 }
552
554 bool checkValid(bool allow_small_deg = true) const;
555
557 bool isValidOrder(const std::vector<PCNode*>& order) const;
558
561 PCTreeNodeArray<ogdf::node>& pc_repr, ogdf::NodeArray<PCNode*>* g_repr = nullptr,
562 bool mark_full = false, bool show_sibs = false) const;
563
568 void getRestrictions(std::vector<std::vector<PCNode*>>& restrictions,
569 PCNode* fixedLeaf = nullptr) const;
570
572 template<typename R>
573 R possibleOrders() const {
574 R orders(1);
575 for (PCNode* node : innerNodes()) {
576 if (node->getNodeType() == PCNodeType::CNode) {
577 orders *= 2;
578 } else {
579 R children(node->getChildCount());
580 if (node == m_rootNode) {
581 children -= 1; // don't count circular shifts
582 }
583 orders *= factorial(children);
584 }
585 }
586 return orders;
587 }
588
594 std::ostream& uniqueID(std::ostream& os,
595 const std::function<void(std::ostream& os, PCNode*, int)>& printNode = uid_utils::nodeToID,
596 const std::function<bool(PCNode*, PCNode*)>& compareNodes = uid_utils::compareNodesByID);
597
598 std::string uniqueID(
599 const std::function<void(std::ostream& os, PCNode*, int)>& printNode = uid_utils::nodeToID,
600 [[maybe_unused]] const std::function<bool(PCNode*, PCNode*)>& compareNodes =
601 uid_utils::compareNodesByID) {
602 std::stringstream sb;
603 uniqueID(sb, printNode, compareNodes);
604 return sb.str();
605 }
606
608
609public:
614 template<typename It>
618
619 NextFullLeaf(It it, It an_end) : m_it(it), m_end(an_end) { }
620
622 if (m_it == m_end) {
623 return nullptr;
624 }
625 PCNode* n = *m_it;
626 ++m_it;
627 return n;
628 }
629 };
630
631 using FullLeafIter = std::function<std::function<PCNode*()>()>;
632
634 struct Observer {
635 enum class Stage { Trivial, NoPartials, InvalidTP, SingletonTP, Done };
636
637 virtual void onNodeCreate([[maybe_unused]] PCNode* node) {};
638
639 virtual void makeConsecutiveCalled([[maybe_unused]] PCTree& tree,
640 [[maybe_unused]] FullLeafIter consecutiveLeaves) {};
641
642 virtual void labelsAssigned([[maybe_unused]] PCTree& tree,
643 [[maybe_unused]] PCNode* firstPartial, [[maybe_unused]] PCNode* lastPartial,
644 [[maybe_unused]] int partialCount) {};
645
646 virtual void terminalPathFound([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* apex,
647 [[maybe_unused]] PCNode* apexTPPred2, [[maybe_unused]] int terminalPathLength) {};
648
649 virtual void centralCreated([[maybe_unused]] PCTree& tree,
650 [[maybe_unused]] PCNode* central) {};
651
652 virtual void beforeMerge([[maybe_unused]] PCTree& tree, [[maybe_unused]] int count,
653 [[maybe_unused]] PCNode* tpNeigh) {};
654
655 virtual void afterMerge([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* successor,
656 [[maybe_unused]] PCNode* mergedNode) {};
657
658 virtual void whenPNodeMerged([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* tpNeigh,
659 [[maybe_unused]] PCNode* tpPred, [[maybe_unused]] PCNode* fullNeigh) {};
660
661 virtual void whenCNodeMerged([[maybe_unused]] PCTree& tree,
662 [[maybe_unused]] PCNode* tpNeigh, [[maybe_unused]] bool tpNeighSiblingsFlipped,
663 [[maybe_unused]] PCNode* fullNeigh, [[maybe_unused]] PCNode* fullOuterChild) {};
664
665 virtual void fullNodeSplit([[maybe_unused]] PCTree& tree,
666 [[maybe_unused]] PCNode* fullNode) {};
667
668 virtual void makeConsecutiveDone([[maybe_unused]] PCTree& tree,
669 [[maybe_unused]] Stage stage, [[maybe_unused]] bool success) {};
670
671 virtual void onApexMoved([[maybe_unused]] PCTree& tree,
672 [[maybe_unused]] PCNode* apexCandidate, [[maybe_unused]] PCNode* central,
673 [[maybe_unused]] PCNode* parent) {};
674
675 virtual void nodeDeleted([[maybe_unused]] PCTree& tree,
676 [[maybe_unused]] PCNode* toBeDeleted) {};
677 virtual void nodeReplaced([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* replaced,
678 [[maybe_unused]] PCNode* replacement) {};
679 };
680
681 struct LoggingObserver : public Observer {
682 void makeConsecutiveCalled(PCTree& tree, FullLeafIter consecutiveLeaves) override;
683
684 void labelsAssigned(PCTree& tree, PCNode* firstPartial, PCNode* lastPartial,
685 int partialCount) override;
686
687 void terminalPathFound(PCTree& tree, PCNode* apex, PCNode* apexTPPred2,
688 int terminalPathLength) override;
689
690 void centralCreated(PCTree& tree, PCNode* central) override;
691
692 void beforeMerge(PCTree& tree, int count, PCNode* tpNeigh) override;
693
694 void makeConsecutiveDone(PCTree& tree, Stage stage, bool success) override;
695 };
696
697 std::list<Observer*>::const_iterator addObserver(Observer* observer) {
698 m_observers.push_back(observer);
699 return --m_observers.end();
700 }
701
702 void removeObserver(std::list<Observer*>::const_iterator it) { m_observers.erase(it); }
703
704 void removeObserver(Observer* observer) { m_observers.remove(observer); }
705
707};
708
709int PCTreeRegistry::keyToIndex(PCNode* key) { return key->index(); }
710
711}
Includes declaration of graph class.
An intrusive list for the leaves of a PCTree.
Predeclaration of various PC-tree related classes and enums.
A node in a PC-tree that is either a P-node, C-node or leaf.
A registry that allows labelling the nodes of a PC-tree.
PCTreeForests contain multiple PCTrees that can be merged with each other.
Utils for PCTree::allNodes(), PCTree::innerNodes(), PCNode::children() and PCNode::neighbors().
Basic declarations, included by all source files.
Stores additional attributes of a graph (like layout information).
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Class for the representation of nodes.
Definition Graph_d.h:241
Dynamic arrays indexed with arbitrary keys.
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
A DFS or BFS through a PCTree.
A node in a PC-tree that is either a P-node, C-node or leaf.
Definition PCNode.h:62
size_t index() const
Definition PCNode.h:452
bool isLeaf() const
Definition PCNode.h:310
void setLabel(NodeLabel l)
Definition PCNode.h:380
PCTreeForest * m_forest
Definition PCNode.h:124
Multiple PCTrees can be created within the same PCTreeForest, which allows merging the trees later on...
PCTreeRegistry m_nodeArrayRegistry
A PC-tree represents a set of cyclic orders of its leaves by labeling its inner nodes as either P- or...
Definition PCTree.h:118
FilteringPCTreeDFS innerNodes() const
An iterable through all inner (non-leaf) nodes of this PCTree.
Definition PCTree.h:532
void removeObserver(Observer *observer)
Definition PCTree.h:704
PCNodeType changeNodeType(PCNode *node, PCNodeType newType)
Change the type of a node and update all its registrations.
bool makeFullNodesConsecutive()
Updates the tree to make all leaves marked as full consecutive in all represented orders.
std::vector< PCNode * > currentLeafOrder() const
Definition PCTree.h:547
void registerNode(PCNode *node)
PCNode * mergeLeaves(It begin, It end, bool assumeConsecutive=false)
Merge multiple leaves into a single one and return it.
Definition PCTree.h:259
void destroyNode(PCNode *&node)
Destroy a node.
Definition PCTree.h:218
int getTerminalPathLength() const
Definition PCTree.h:526
void replaceTPNeigh(PCNode *central, PCNode *oldTPNeigh, PCNode *newTPNeigh, PCNode *newFullNeigh, PCNode *otherEndOfFullBlock)
bool isTrivial() const
Whether this PCTree allows all orders (consists of a single P-node).
size_t getPNodeCount() const
Definition PCTree.h:517
void insertLeaves(int count, PCNode *parent, std::vector< PCNode * > *added=nullptr)
Attach count leaves to P- or C-node parent and optionally store the new leaves in a vector added.
PCNode * mergeLeaves(const std::vector< PCNode * > &consecutiveLeaves, bool assumeConsecutive=false)
Merge multiple leaves into a single one and return it.
Definition PCTree.h:246
bool isTrivialRestriction(int size) const
bool isValidOrder(const std::vector< PCNode * > &order) const
Check whether the order order is represented by this tree.
std::string uniqueID(const std::function< void(std::ostream &os, PCNode *, int)> &printNode=uid_utils::nodeToID, const std::function< bool(PCNode *, PCNode *)> &compareNodes=uid_utils::compareNodesByID)
Definition PCTree.h:598
bool setApexCandidate(PCNode *ac, bool fix=false)
FilteringPCTreeDFS allNodes() const
An iterable through all nodes of this PCTree.
Definition PCTree.h:529
PCNode * createCentralNode()
PCNode * getRootNode() const
Definition PCTree.h:521
PCTree(int leafNum, std::vector< PCNode * > *added=nullptr, PCTreeForest *forest=nullptr)
Convenience method generating a PCTree consisting of a single P-node with leafNum leaves,...
PCTree()
Constructs a new PCTree.
Definition PCTree.h:159
size_t getCNodeCount() const
Definition PCTree.h:519
bool makeConsecutive(It begin, It end)
Make the leaves contained in the range denoted by iterators begin (inclusive) to end (exclusive) cons...
Definition PCTree.h:352
void addPartialNode(PCNode *partial)
void resetTempData()
Reset all makeConsecutive()-related temporary information, especially which leaves are full (should b...
Definition PCTree.h:386
PCTreeForest * getForest() const
The PCTreeForest this PCTree belongs to, or nullptr.
Definition PCTree.h:508
PCNode * splitOffFullPNode(PCNode *node, bool skip_parent)
void getRestrictions(std::vector< std::vector< PCNode * > > &restrictions, PCNode *fixedLeaf=nullptr) const
Get a list of all cyclic restrictions used to generate this tree.
void insertTree(PCNode *at, PCTree *tree)
Insert tree tree into this tree at node at.
std::ostream & uniqueID(std::ostream &os, const std::function< void(std::ostream &os, PCNode *, int)> &printNode=uid_utils::nodeToID, const std::function< bool(PCNode *, PCNode *)> &compareNodes=uid_utils::compareNodesByID)
Print a deterministic and unique representation of this PCTree to os.
void unregisterNode(PCNode *node)
void getTree(ogdf::Graph &tree, ogdf::GraphAttributes *g_a, PCTreeNodeArray< ogdf::node > &pc_repr, ogdf::NodeArray< PCNode * > *g_repr=nullptr, bool mark_full=false, bool show_sibs=false) const
Get a graphical representation of this tree as Graph.
void replaceLeaf(int leafCount, PCNode *leaf, std::vector< PCNode * > *added=nullptr)
Convert leaf into a P-node and attach leafCount new leaves to it.
friend std::ostream & operator<<)(std::ostream &, const ogdf::pc_tree::PCNode *)
PCTree(const std::string &str, bool keep_ids=false, PCTreeForest *forest=nullptr)
Deserialize a PCTree from a string str as generated by operator<<(std::ostream&, const PCTree*) or PC...
void markFull(It begin, It end, std::vector< PCNode * > *fullNodeOrder=nullptr)
Marks the leaves contained in the range denoted by iterators begin (inclusive) to end (exclusive) ful...
Definition PCTree.h:417
size_t getLeafCount() const
Definition PCTree.h:515
size_t findEndOfFullBlock(PCNode *node, PCNode *pred, PCNode *curr, PCNode *&fullEnd, PCNode *&emptyEnd) const
bool checkValid(bool allow_small_deg=true) const
Validity check for debugging assertions.
friend std::ostream & operator<<)(std::ostream &, const ogdf::pc_tree::PCTree *)
const IntrusiveList< PCNode > & getLeaves() const
Definition PCTree.h:513
void restoreSubtrees(PCTreeNodeArray< std::vector< PCNode * > > &blockNodes, PCTreeNodeArray< std::vector< PCNode * > > &subtreeNodes, PCTreeNodeArray< PCNode * > &leafPartner, PCTreeNodeArray< bool > &isFront)
bool makeConsecutive(const std::vector< PCNode * > &consecutiveLeaves)
Definition PCTree.h:340
std::list< Observer * >::const_iterator addObserver(Observer *observer)
Definition PCTree.h:697
PCTree(const PCTree &other, PCTreeNodeArray< PCNode * > &nodeMapping, bool keep_ids=false, PCTreeForest *forest=nullptr)
Copy a PCTree.
bool makeConsecutive(std::initializer_list< PCNode * > consecutiveLeaves)
Definition PCTree.h:336
void removeObserver(std::list< Observer * >::const_iterator it)
Definition PCTree.h:702
PCNode * markFull(PCNode *full_node, std::vector< PCNode * > *fullNodeOrder=nullptr)
bool findNodeRestrictions(PCTree &applyTo, PCTreeNodeArray< PCNode * > &mapping, PCTreeNodeArray< std::vector< PCNode * > > &blockNodes, PCTreeNodeArray< std::vector< PCNode * > > &subtreeNodes, PCTreeNodeArray< PCNode * > &leafPartner, PCTreeNodeArray< bool > &isFront)
PCTree(PCTreeForest *forest)
Constructs a new PCTree that is part of forest and can thus be merged with any other PCTree of the sa...
Definition PCTree.h:164
void removePartialNode(PCNode *partial)
bool checkTPPartialCNode(PCNode *node)
PCNode * changeRoot(PCNode *newRoot)
Change the orientation of edges such that newRoot becomes the root of the tree.
std::function< std::function< PCNode *()>()> FullLeafIter
Definition PCTree.h:631
IntrusiveList< PCNode > m_leaves
Definition PCTree.h:136
void currentLeafOrder(Container &container) const
Store the order of leaves currently represented by this tree in container.
Definition PCTree.h:538
bool intersect(PCTree &other, PCTreeNodeArray< PCNode * > &mapping)
Intersect the restrictions represented by this tree with those represented by other,...
PCNode * setRoot(PCNode *newRoot)
Overwrite the stored root for this PC-tree.
std::list< Observer * > m_observers
Definition PCTree.h:152
void updateSingletonTerminalPath()
void destroyNode(PCNode *const &node)
Destroy a node.
int updateTerminalPath(PCNode *central, PCNode *tpNeigh)
R possibleOrders() const
Calculate the number of cyclic orders represented by this tree.
Definition PCTree.h:573
void destroyLeaf(PCNode *leaf)
Remove a leaf and also any newly-introduced inner degree-2 or -1 nodes.
PCNode * newNode(PCNodeType type, PCNode *parent=nullptr, int id=-1)
Create a new node.
void markLeavesFull(It begin, It end)
Only marks leaves full, does not update partial/full info of parents.
Definition PCTree.h:401
A registry that allows labelling the nodes of a PC-tree.
Definition PCRegistry.h:44
static int keyToIndex(PCNode *key)
Returns the index of key.
Definition PCTree.h:709
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_HEAVY_ASSERT(expr)
Assert condition expr when using heavy debugging. See OGDF_ASSERT.
Definition basic.h:55
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
void nodeToID(std::ostream &os, PCNode *n, int pos)
Print the index of a node n.
void nodeToPosition(std::ostream &os, PCNode *n, int pos)
Print the position pos of a node n.
void leafToPosition(std::ostream &os, PCNode *n, int pos)
Print the position pos of a node n if it is a leaf.
bool compareNodesByID(PCNode *a, PCNode *b)
Sort nodes by ascending index.
void leafToID(std::ostream &os, PCNode *n, int pos)
Print the index of a node n if it is a leaf.
bool isTrivialRestriction(int restSize, int leafCount)
int PCTREE_DEBUG_CHECK_FREQ
Allows controlling the frequency of full-tree consistency checks in heavy debug mode.
int factorial(int n)
The namespace for all OGDF objects.
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
void centralCreated(PCTree &tree, PCNode *central) override
void makeConsecutiveCalled(PCTree &tree, FullLeafIter consecutiveLeaves) override
void labelsAssigned(PCTree &tree, PCNode *firstPartial, PCNode *lastPartial, int partialCount) override
void makeConsecutiveDone(PCTree &tree, Stage stage, bool success) override
void beforeMerge(PCTree &tree, int count, PCNode *tpNeigh) override
void terminalPathFound(PCTree &tree, PCNode *apex, PCNode *apexTPPred2, int terminalPathLength) override
NextFullLeaf(It it, It an_end)
Definition PCTree.h:619
Interface for Observers that can be notified of all changes made to the tree during an update.
Definition PCTree.h:634
virtual void nodeReplaced(PCTree &tree, PCNode *replaced, PCNode *replacement)
Definition PCTree.h:677
virtual void whenCNodeMerged(PCTree &tree, PCNode *tpNeigh, bool tpNeighSiblingsFlipped, PCNode *fullNeigh, PCNode *fullOuterChild)
Definition PCTree.h:661
virtual void centralCreated(PCTree &tree, PCNode *central)
Definition PCTree.h:649
virtual void makeConsecutiveCalled(PCTree &tree, FullLeafIter consecutiveLeaves)
Definition PCTree.h:639
virtual void nodeDeleted(PCTree &tree, PCNode *toBeDeleted)
Definition PCTree.h:675
virtual void afterMerge(PCTree &tree, PCNode *successor, PCNode *mergedNode)
Definition PCTree.h:655
virtual void fullNodeSplit(PCTree &tree, PCNode *fullNode)
Definition PCTree.h:665
virtual void terminalPathFound(PCTree &tree, PCNode *apex, PCNode *apexTPPred2, int terminalPathLength)
Definition PCTree.h:646
virtual void labelsAssigned(PCTree &tree, PCNode *firstPartial, PCNode *lastPartial, int partialCount)
Definition PCTree.h:642
virtual void whenPNodeMerged(PCTree &tree, PCNode *tpNeigh, PCNode *tpPred, PCNode *fullNeigh)
Definition PCTree.h:658
virtual void makeConsecutiveDone(PCTree &tree, Stage stage, bool success)
Definition PCTree.h:668
virtual void onApexMoved(PCTree &tree, PCNode *apexCandidate, PCNode *central, PCNode *parent)
Definition PCTree.h:671
virtual void onNodeCreate(PCNode *node)
Definition PCTree.h:637
virtual void beforeMerge(PCTree &tree, int count, PCNode *tpNeigh)
Definition PCTree.h:652