Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

PCTree.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/Graph.h>
42 
43 #include <deque>
44 #include <list>
45 #include <sstream>
46 #include <vector>
47 
48 namespace ogdf::pc_tree {
53 OGDF_EXPORT bool isTrivialRestriction(int restSize, int leafCount);
54 
55 OGDF_EXPORT int factorial(int n);
56 
57 #ifdef OGDF_DEBUG
58 
66 #endif
67 
71 namespace uid_utils {
75 OGDF_EXPORT void nodeToID(std::ostream& os, PCNode* n, int pos);
76 
80 OGDF_EXPORT void nodeToPosition(std::ostream& os, PCNode* n, int pos);
81 
85 OGDF_EXPORT void leafToID(std::ostream& os, PCNode* n, int pos);
86 
90 OGDF_EXPORT void leafToPosition(std::ostream& os, PCNode* n, int pos);
91 
96 }
97 
110  friend OGDF_EXPORT std::ostream&(operator<<)(std::ostream&, const ogdf::pc_tree::PCTree*);
111  friend OGDF_EXPORT std::ostream&(operator<<)(std::ostream&, const ogdf::pc_tree::PCNode*);
112 
113  friend class PCNode;
114  friend class PCTreeRegistry;
115  friend class PCTreeForest;
116 
117 public:
118  struct Observer; // pre-declaration
119 
120 private:
121  // global
122  PCTreeForest* m_forest = nullptr;
123 
124  // needs merge when trees merge
125  size_t m_pNodeCount = 0;
126  size_t m_cNodeCount = 0;
128 
129  // needs special merge
130  PCNode* m_rootNode = nullptr;
131 
132  // temp makeConsecutive variables
133  size_t m_partialCount = 0;
134  size_t m_terminalPathLength = 0;
135  PCNode* m_firstPartial = nullptr;
136  PCNode* m_lastPartial = nullptr;
137  PCNode* m_apexCandidate = nullptr;
138  bool m_apexCandidateIsFix = false;
139  PCNode* m_apexTPPred2 = nullptr;
140 
141  // private
142  bool m_externalForest = true;
143  std::list<Observer*> m_observers;
144 
145 public:
150  explicit PCTree() : PCTree(nullptr) {};
151 
155  explicit PCTree(PCTreeForest* forest) {
156  if (forest) {
157  m_forest = forest;
158  m_externalForest = true;
159  } else {
160  m_forest = new PCTreeForest();
161  m_externalForest = false;
162  }
163  };
164 
169  explicit PCTree(int leafNum, std::vector<PCNode*>* added = nullptr,
170  PCTreeForest* forest = nullptr);
171 
179  explicit PCTree(const PCTree& other, PCTreeNodeArray<PCNode*>& nodeMapping,
180  bool keep_ids = false, PCTreeForest* forest = nullptr);
181 
186  explicit PCTree(const std::string& str, bool keep_ids = false, PCTreeForest* forest = nullptr);
187 
188  virtual ~PCTree();
189 
190 public:
194 
203  PCNode* newNode(PCNodeType type, PCNode* parent = nullptr, int id = -1);
204 
210  destroyNode((PCNode* const&)node);
211  node = nullptr;
212  }
213 
218  void destroyNode(PCNode* const& node);
219 
223  void insertLeaves(int count, PCNode* parent, std::vector<PCNode*>* added = nullptr);
224 
228  void replaceLeaf(int leafCount, PCNode* leaf, std::vector<PCNode*>* added = nullptr);
229 
237  PCNode* mergeLeaves(const std::vector<PCNode*>& consecutiveLeaves,
238  bool assumeConsecutive = false) {
239  return mergeLeaves(consecutiveLeaves.begin(), consecutiveLeaves.end(), assumeConsecutive);
240  }
241 
249  template<typename It>
250  PCNode* mergeLeaves(It begin, It end, bool assumeConsecutive = false) {
251  OGDF_ASSERT(begin != end);
252 
253  if (!assumeConsecutive && !makeConsecutive(begin, end)) {
254  return nullptr;
255  }
256 
257  // Remove all consecutive leaves except the first one.
258  It back = prev(end);
259  for (auto it = begin; it != back; ++it) {
260  destroyLeaf(*it);
261  }
262 
263  OGDF_HEAVY_ASSERT(checkValid());
264 
265  // Return the remaining leaf.
266  return *back;
267  }
268 
275  void destroyLeaf(PCNode* leaf);
276 
284  PCNode* setRoot(PCNode* newRoot);
285 
292  PCNode* changeRoot(PCNode* newRoot);
293 
298  PCNodeType changeNodeType(PCNode* node, PCNodeType newType);
299 
306  void insertTree(PCNode* at, PCTree* tree);
307 
308 private:
309  void unregisterNode(PCNode* node);
310 
311  void registerNode(PCNode* node);
312 
314 
315 public:
319 
325  bool isTrivialRestriction(int size) const;
326 
327  bool makeConsecutive(std::initializer_list<PCNode*> consecutiveLeaves) {
328  return makeConsecutive(consecutiveLeaves.begin(), consecutiveLeaves.end());
329  }
330 
331  bool makeConsecutive(const std::vector<PCNode*>& consecutiveLeaves) {
332  return makeConsecutive(consecutiveLeaves.begin(), consecutiveLeaves.end());
333  }
334 
342  template<typename It>
343  bool makeConsecutive(It begin, It end) {
344  FullLeafIter iter = [&begin, &end]() { return NextFullLeaf<It>(begin, end); };
345  for (auto obs : m_observers) {
346  obs->makeConsecutiveCalled(*this, iter);
347  }
348 
349  OGDF_HEAVY_ASSERT(checkValid());
350  resetTempData();
351 
352 #ifdef OGDF_DEBUG
353  for (auto it = begin; it != end; ++it) {
354  PCNode* leaf = *it;
355  OGDF_ASSERT(leaf);
356  OGDF_ASSERT(leaf->isLeaf());
357  OGDF_ASSERT(leaf->m_forest == m_forest);
358  }
359 #endif
360  if (isTrivialRestriction(end - begin)) {
361  for (auto obs : m_observers) {
362  obs->makeConsecutiveDone(*this, Observer::Stage::Trivial, true);
363  }
364  return true;
365  }
366 
367  // PC_PROFILE_ENTER(1, "label");
368  markFull(begin, end);
369  // PC_PROFILE_EXIT(1, "label");
370 
371  return makeFullNodesConsecutive();
372  }
373 
377  void resetTempData() {
378  m_forest->m_timestamp++;
379  m_firstPartial = m_lastPartial = nullptr;
380  m_partialCount = 0;
381  m_apexCandidate = nullptr;
382  m_apexCandidateIsFix = false;
383  m_terminalPathLength = 0;
384  m_apexTPPred2 = nullptr;
385  }
386 
391  template<typename It>
392  void markLeavesFull(It begin, It end) {
393  for (auto it = begin; it != end; ++it) {
394  PCNode* leaf = *it;
395  OGDF_ASSERT(leaf);
396  OGDF_ASSERT(leaf->isLeaf());
397  OGDF_ASSERT(leaf->m_forest == m_forest);
398  leaf->setLabel(NodeLabel::Full);
399  }
400  }
401 
407  template<typename It>
408  void markFull(It begin, It end, std::vector<PCNode*>* fullNodeOrder = nullptr) {
409  // Attention: This method no longer uses a queue to defer processing of partial/full parents to after
410  // all leaves are done, but now directly make parents full if all of their children are full.
411  if (fullNodeOrder != nullptr) {
412  fullNodeOrder->reserve(m_cNodeCount + m_pNodeCount);
413  }
414 
415  for (auto it = begin; it != end; ++it) {
416  PCNode* full_parent = markFull(*it, fullNodeOrder);
417  while (full_parent != nullptr) {
418  full_parent = markFull(full_parent, fullNodeOrder);
419  }
420  }
421  }
422 
429  bool makeFullNodesConsecutive();
430 
431 private:
432  /* see the paper for more info on how the update works with the following methods */
433 
434  PCNode* markFull(PCNode* full_node, std::vector<PCNode*>* fullNodeOrder = nullptr);
435 
436  bool findTerminalPath();
437 
438  void updateSingletonTerminalPath();
439 
440  PCNode* createCentralNode();
441 
442  int updateTerminalPath(PCNode* central, PCNode* tpNeigh);
443 
444  // labeling / TP finding
445 
446  void addPartialNode(PCNode* partial);
447 
448  void removePartialNode(PCNode* partial);
449 
450  bool checkTPPartialCNode(PCNode* node);
451 
452  size_t findEndOfFullBlock(PCNode* node, PCNode* pred, PCNode* curr, PCNode*& fullEnd,
453  PCNode*& emptyEnd) const;
454 
455  bool setApexCandidate(PCNode* ac, bool fix = false);
456 
457  // update
458 
459  void replaceTPNeigh(PCNode* central, PCNode* oldTPNeigh, PCNode* newTPNeigh,
460  PCNode* newFullNeigh, PCNode* otherEndOfFullBlock);
461 
462  PCNode* splitOffFullPNode(PCNode* node, bool skip_parent);
463 
465 
466 public:
470 
477  bool intersect(PCTree& other, PCTreeNodeArray<PCNode*>& mapping);
478 
479 private:
480  bool findNodeRestrictions(PCTree& applyTo, PCTreeNodeArray<PCNode*>& mapping,
481  PCTreeNodeArray<std::vector<PCNode*>>& blockNodes,
482  PCTreeNodeArray<std::vector<PCNode*>>& subtreeNodes,
483  PCTreeNodeArray<PCNode*>& leafPartner, PCTreeNodeArray<bool>& isFront);
484 
485  void restoreSubtrees(PCTreeNodeArray<std::vector<PCNode*>>& blockNodes,
486  PCTreeNodeArray<std::vector<PCNode*>>& subtreeNodes,
487  PCTreeNodeArray<PCNode*>& leafPartner, PCTreeNodeArray<bool>& isFront);
488 
490 
491 public:
495  operator const PCTreeRegistry&() const { return m_forest->m_nodeArrayRegistry; }
497 
499  [[nodiscard]] PCTreeForest* getForest() const { return m_forest; }
500 
502  [[nodiscard]] bool isTrivial() const;
503 
504  [[nodiscard]] const IntrusiveList<PCNode>& getLeaves() const { return m_leaves; }
505 
506  [[nodiscard]] size_t getLeafCount() const { return m_leaves.size(); };
507 
508  [[nodiscard]] size_t getPNodeCount() const { return m_pNodeCount; }
509 
510  [[nodiscard]] size_t getCNodeCount() const { return m_cNodeCount; }
511 
512  [[nodiscard]] PCNode* getRootNode() const { return m_rootNode; }
513 
517  int getTerminalPathLength() const { return m_terminalPathLength; }
518 
520  FilteringPCTreeDFS allNodes() const { return FilteringPCTreeDFS(*this, m_rootNode); }
521 
524  return FilteringPCTreeDFS(*this, m_rootNode, [](PCNode* node) { return !node->isLeaf(); });
525  }
526 
528  template<typename Container>
529  void currentLeafOrder(Container& container) const {
530  for (PCNode* leaf : FilteringPCTreeDFS(*this, m_rootNode)) {
531  if (leaf->isLeaf()) {
532  container.push_back(leaf);
533  }
534  }
535  OGDF_ASSERT(container.size() == m_leaves.size());
536  }
537 
538  std::vector<PCNode*> currentLeafOrder() const {
539  std::vector<PCNode*> container;
540  currentLeafOrder(container);
541  return container;
542  }
543 
545  bool checkValid(bool allow_small_deg = true) const;
546 
548  bool isValidOrder(const std::vector<PCNode*>& order) const;
549 
551  void getTree(ogdf::Graph& tree, ogdf::GraphAttributes* g_a,
552  PCTreeNodeArray<ogdf::node>& pc_repr, ogdf::NodeArray<PCNode*>* g_repr = nullptr,
553  bool mark_full = false, bool show_sibs = false) const;
554 
559  void getRestrictions(std::vector<std::vector<PCNode*>>& restrictions,
560  PCNode* fixedLeaf = nullptr) const;
561 
563  template<typename R>
564  R possibleOrders() const {
565  R orders(1);
566  for (PCNode* node : innerNodes()) {
567  if (node->getNodeType() == PCNodeType::CNode) {
568  orders *= 2;
569  } else {
570  R children(node->getChildCount());
571  if (node == m_rootNode) {
572  children -= 1; // don't count circular shifts
573  }
574  orders *= factorial(children);
575  }
576  }
577  return orders;
578  }
579 
585  std::ostream& uniqueID(std::ostream& os,
586  const std::function<void(std::ostream& os, PCNode*, int)>& printNode = uid_utils::nodeToID,
587  const std::function<bool(PCNode*, PCNode*)>& compareNodes = uid_utils::compareNodesByID);
588 
589  std::string uniqueID(
590  const std::function<void(std::ostream& os, PCNode*, int)>& printNode = uid_utils::nodeToID,
591  [[maybe_unused]] const std::function<bool(PCNode*, PCNode*)>& compareNodes =
593  std::stringstream sb;
594  uniqueID(sb, printNode, compareNodes);
595  return sb.str();
596  }
597 
599 
600 public:
604  template<typename It>
606  struct NextFullLeaf {
607  It m_it;
608  It m_end;
609 
610  NextFullLeaf(It it, It an_end) : m_it(it), m_end(an_end) { }
611 
613  if (m_it == m_end) {
614  return nullptr;
615  }
616  PCNode* n = *m_it;
617  ++m_it;
618  return n;
619  }
620  };
621 
622  using FullLeafIter = std::function<std::function<PCNode*()>()>;
623 
625  struct Observer {
626  enum class Stage { Trivial, NoPartials, InvalidTP, SingletonTP, Done };
627 
628  virtual void onNodeCreate([[maybe_unused]] PCNode* node) {};
629 
630  virtual void makeConsecutiveCalled([[maybe_unused]] PCTree& tree,
631  [[maybe_unused]] FullLeafIter consecutiveLeaves) {};
632 
633  virtual void labelsAssigned([[maybe_unused]] PCTree& tree,
634  [[maybe_unused]] PCNode* firstPartial, [[maybe_unused]] PCNode* lastPartial,
635  [[maybe_unused]] int partialCount) {};
636 
637  virtual void terminalPathFound([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* apex,
638  [[maybe_unused]] PCNode* apexTPPred2, [[maybe_unused]] int terminalPathLength) {};
639 
640  virtual void centralCreated([[maybe_unused]] PCTree& tree,
641  [[maybe_unused]] PCNode* central) {};
642 
643  virtual void beforeMerge([[maybe_unused]] PCTree& tree, [[maybe_unused]] int count,
644  [[maybe_unused]] PCNode* tpNeigh) {};
645 
646  virtual void afterMerge([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* successor,
647  [[maybe_unused]] PCNode* mergedNode) {};
648 
649  virtual void whenPNodeMerged([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* tpNeigh,
650  [[maybe_unused]] PCNode* tpPred, [[maybe_unused]] PCNode* fullNeigh) {};
651 
652  virtual void whenCNodeMerged([[maybe_unused]] PCTree& tree,
653  [[maybe_unused]] PCNode* tpNeigh, [[maybe_unused]] bool tpNeighSiblingsFlipped,
654  [[maybe_unused]] PCNode* fullNeigh, [[maybe_unused]] PCNode* fullOuterChild) {};
655 
656  virtual void fullNodeSplit([[maybe_unused]] PCTree& tree,
657  [[maybe_unused]] PCNode* fullNode) {};
658 
659  virtual void makeConsecutiveDone([[maybe_unused]] PCTree& tree,
660  [[maybe_unused]] Stage stage, [[maybe_unused]] bool success) {};
661 
662  virtual void onApexMoved([[maybe_unused]] PCTree& tree,
663  [[maybe_unused]] PCNode* apexCandidate, [[maybe_unused]] PCNode* central,
664  [[maybe_unused]] PCNode* parent) {};
665 
666  virtual void nodeDeleted([[maybe_unused]] PCTree& tree,
667  [[maybe_unused]] PCNode* toBeDeleted) {};
668  virtual void nodeReplaced([[maybe_unused]] PCTree& tree, [[maybe_unused]] PCNode* replaced,
669  [[maybe_unused]] PCNode* replacement) {};
670  };
671 
672  struct LoggingObserver : public Observer {
673  void makeConsecutiveCalled(PCTree& tree, FullLeafIter consecutiveLeaves) override;
674 
675  void labelsAssigned(PCTree& tree, PCNode* firstPartial, PCNode* lastPartial,
676  int partialCount) override;
677 
678  void terminalPathFound(PCTree& tree, PCNode* apex, PCNode* apexTPPred2,
679  int terminalPathLength) override;
680 
681  void centralCreated(PCTree& tree, PCNode* central) override;
682 
683  void beforeMerge(PCTree& tree, int count, PCNode* tpNeigh) override;
684 
685  void makeConsecutiveDone(PCTree& tree, Stage stage, bool success) override;
686  };
687 
688  std::list<Observer*>::const_iterator addObserver(Observer* observer) {
689  m_observers.push_back(observer);
690  return --m_observers.end();
691  }
692 
693  void removeObserver(std::list<Observer*>::const_iterator it) { m_observers.erase(it); }
694 
695  void removeObserver(Observer* observer) { m_observers.remove(observer); }
696 
698 };
699 
700 int PCTreeRegistry::keyToIndex(PCNode* key) { return key->index(); }
701 
702 }
ogdf::pc_tree::PCTree::NextFullLeaf::operator()
PCNode * operator()()
Definition: PCTree.h:612
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:66
GraphAttributes.h
Declaration of class GraphAttributes which extends a Graph by additional attributes.
ogdf::RegisteredArray
Dynamic arrays indexed with arbitrary keys.
Definition: RegisteredArray.h:808
ogdf::pc_tree::PCNodeType::CNode
@ CNode
ogdf::pc_tree::PCTree::getPNodeCount
size_t getPNodeCount() const
Definition: PCTree.h:508
Graph.h
Includes declaration of graph class.
ogdf::pc_tree::uid_utils::nodeToPosition
void nodeToPosition(std::ostream &os, PCNode *n, int pos)
Print the position pos of a node n.
ogdf::pc_tree::PCNode::m_forest
PCTreeForest * m_forest
Definition: PCNode.h:120
ogdf::pc_tree::FilteringPCTreeDFS
FilteringPCTreeWalk< true > FilteringPCTreeDFS
Definition: PCTreeIterators.h:214
ogdf::pc_tree::PCNode::index
size_t index() const
Definition: PCNode.h:448
ogdf::pc_tree::PCTree::resetTempData
void resetTempData()
Reset all makeConsecutive()-related temporary information, especially which leaves are full (should b...
Definition: PCTree.h:377
ogdf::pc_tree::PCTree::addObserver
std::list< Observer * >::const_iterator addObserver(Observer *observer)
Definition: PCTree.h:688
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::pc_tree::PCTree::getForest
PCTreeForest * getForest() const
The PCTreeForest this PCTree belongs to, or nullptr.
Definition: PCTree.h:499
ogdf::begin
HypergraphRegistry< HypernodeElement >::iterator begin(const HypergraphRegistry< HypernodeElement > &self)
ogdf::pc_tree::PCTree::makeConsecutive
bool makeConsecutive(std::initializer_list< PCNode * > consecutiveLeaves)
Definition: PCTree.h:327
ogdf::pc_tree
Definition: NodePCRotation.h:37
OGDF_HEAVY_ASSERT
#define OGDF_HEAVY_ASSERT(expr)
Assert condition expr when using heavy debugging. See OGDF_ASSERT.
Definition: basic.h:44
ogdf::pc_tree::PCTree
A PC-tree represents a set of cyclic orders of its leaves by labeling its inner nodes as either P- or...
Definition: PCTree.h:109
ogdf::pc_tree::PCTree::Observer::makeConsecutiveDone
virtual void makeConsecutiveDone([[maybe_unused]] PCTree &tree, [[maybe_unused]] Stage stage, [[maybe_unused]] bool success)
Definition: PCTree.h:659
IntrusiveList.h
An intrusive list for the leaves of a PCTree. TODO should be moved to a central location; merge with ...
ogdf::pc_tree::PCTree::destroyNode
void destroyNode(PCNode *&node)
Destroy a node.
Definition: PCTree.h:209
ogdf::pc_tree::PCTree::innerNodes
FilteringPCTreeDFS innerNodes() const
An iterable through all inner (non-leaf) nodes of this PCTree.
Definition: PCTree.h:523
ogdf::pc_tree::PCTreeRegistry
A registry that allows labelling the nodes of a PC-tree.
Definition: PCRegistry.h:40
ogdf::pc_tree::PCTree::m_leaves
IntrusiveList< PCNode > m_leaves
Definition: PCTree.h:127
ogdf::pc_tree::PCTree::Observer::centralCreated
virtual void centralCreated([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *central)
Definition: PCTree.h:640
ogdf::pc_tree::PCTree::makeConsecutive
bool makeConsecutive(const std::vector< PCNode * > &consecutiveLeaves)
Definition: PCTree.h:331
ogdf::pc_tree::PCNode::isLeaf
bool isLeaf() const
Definition: PCNode.h:306
ogdf::pc_tree::PCTreeForest::m_nodeArrayRegistry
PCTreeRegistry m_nodeArrayRegistry
Definition: PCTreeForest.h:64
ogdf::pc_tree::PCTree::Observer
Interface for Observers that can be notified of all changes made to the tree during an update.
Definition: PCTree.h:625
ogdf::pc_tree::PCNodeType
PCNodeType
Definition: PCEnum.h:42
ogdf::pc_tree::PCTree::PCTree
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:155
ogdf::pc_tree::PCTree::Observer::afterMerge
virtual void afterMerge([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *successor, [[maybe_unused]] PCNode *mergedNode)
Definition: PCTree.h:646
ogdf::pc_tree::IntrusiveList::size
size_t size() const
Definition: IntrusiveList.h:98
ogdf::pc_tree::PCTree::Observer::fullNodeSplit
virtual void fullNodeSplit([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *fullNode)
Definition: PCTree.h:656
ogdf::pc_tree::FilteringPCTreeWalk
A DFS or BFS through a PCTree.
Definition: PCTreeIterators.h:123
ogdf::pc_tree::PCTree::markLeavesFull
void markLeavesFull(It begin, It end)
Only marks leaves full, does not update partial/full info of parents.
Definition: PCTree.h:392
ogdf::pc_tree::PCTree::uniqueID
std::string uniqueID(const std::function< void(std::ostream &os, PCNode *, int)> &printNode=uid_utils::nodeToID, [[maybe_unused]] const std::function< bool(PCNode *, PCNode *)> &compareNodes=uid_utils::compareNodesByID)
Definition: PCTree.h:589
ogdf::pc_tree::PCNode::setLabel
void setLabel(NodeLabel l)
Definition: PCNode.h:376
ogdf::pc_tree::PCTree::Observer::labelsAssigned
virtual void labelsAssigned([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *firstPartial, [[maybe_unused]] PCNode *lastPartial, [[maybe_unused]] int partialCount)
Definition: PCTree.h:633
ogdf::pc_tree::IntrusiveList
Definition: IntrusiveList.h:41
ogdf::pc_tree::uid_utils::leafToPosition
void leafToPosition(std::ostream &os, PCNode *n, int pos)
Print the position pos of a node n if it is a leaf.
ogdf::pc_tree::PCTreeForest
Multiple PCTrees can be created within the same PCTreeForest, which allows merging the trees later on...
Definition: PCTreeForest.h:53
ogdf::pc_tree::PCTree::removeObserver
void removeObserver(Observer *observer)
Definition: PCTree.h:695
backward::Color::type
type
Definition: backward.hpp:1716
ogdf::pc_tree::PCTree::m_observers
std::list< Observer * > m_observers
Definition: PCTree.h:143
ogdf::pc_tree::NodeLabel::Full
@ Full
ogdf::pc_tree::PCTree::getLeafCount
size_t getLeafCount() const
Definition: PCTree.h:506
ogdf::pc_tree::PCTree::Observer::nodeReplaced
virtual void nodeReplaced([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *replaced, [[maybe_unused]] PCNode *replacement)
Definition: PCTree.h:668
ogdf::pc_tree::PCTree::LoggingObserver
Definition: PCTree.h:672
ogdf::pc_tree::isTrivialRestriction
bool isTrivialRestriction(int restSize, int leafCount)
ogdf::pc_tree::PCTree::NextFullLeaf::m_end
It m_end
Definition: PCTree.h:608
ogdf::pc_tree::PCTree::Observer::Stage
Stage
Definition: PCTree.h:626
ogdf::pc_tree::factorial
int factorial(int n)
Returns n!.
Definition: Math.h:143
PCRegistry.h
A registry that allows labelling the nodes of a PC-tree.
ogdf::pc_tree::PCTree::getLeaves
const IntrusiveList< PCNode > & getLeaves() const
Definition: PCTree.h:504
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::pc_tree::PCTree::NextFullLeaf::m_it
It m_it
Definition: PCTree.h:607
ogdf::pc_tree::PCTree::markFull
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:408
ogdf::pc_tree::PCTree::removeObserver
void removeObserver(std::list< Observer * >::const_iterator it)
Definition: PCTree.h:693
ogdf::pc_tree::uid_utils::nodeToID
void nodeToID(std::ostream &os, PCNode *n, int pos)
Print the index of a node n.
ogdf::pc_tree::uid_utils::leafToID
void leafToID(std::ostream &os, PCNode *n, int pos)
Print the index of a node n if it is a leaf.
ogdf::EdgeStandardType::tree
@ tree
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
ogdf::pc_tree::PCTree::getTerminalPathLength
int getTerminalPathLength() const
Definition: PCTree.h:517
PCEnum.h
Predeclaration of various PC-tree related classes and enums.
PCTreeIterators.h
Utils for PCTree::allNodes(), PCTree::innerNodes(), PCNode::children() and PCNode::neighbors().
ogdf::pc_tree::PCTree::getRootNode
PCNode * getRootNode() const
Definition: PCTree.h:512
ogdf::pc_tree::PCTreeForest::m_timestamp
size_t m_timestamp
Definition: PCTreeForest.h:63
ogdf::pc_tree::PCNode
A node in a PC-tree that is either a P-node, C-node or leaf.
Definition: PCNode.h:58
ogdf::pc_tree::PCTree::allNodes
FilteringPCTreeDFS allNodes() const
An iterable through all nodes of this PCTree.
Definition: PCTree.h:520
PCNode.h
A node in a PC-tree that is either a P-node, C-node or leaf.
ogdf::pc_tree::PCTree::Observer::beforeMerge
virtual void beforeMerge([[maybe_unused]] PCTree &tree, [[maybe_unused]] int count, [[maybe_unused]] PCNode *tpNeigh)
Definition: PCTree.h:643
ogdf::end
HypergraphRegistry< HypernodeElement >::iterator end(const HypergraphRegistry< HypernodeElement > &self)
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::pc_tree::PCTree::makeConsecutive
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:343
ogdf::pc_tree::PCTREE_DEBUG_CHECK_FREQ
int PCTREE_DEBUG_CHECK_FREQ
Allows controlling the frequency of full-tree consistency checks in heavy debug mode.
ogdf::pc_tree::PCTree::mergeLeaves
PCNode * mergeLeaves(It begin, It end, bool assumeConsecutive=false)
Merge multiple leaves into a single one and return it.
Definition: PCTree.h:250
ogdf::pc_tree::PCTree::Observer::makeConsecutiveCalled
virtual void makeConsecutiveCalled([[maybe_unused]] PCTree &tree, [[maybe_unused]] FullLeafIter consecutiveLeaves)
Definition: PCTree.h:630
ogdf::pc_tree::PCTree::currentLeafOrder
std::vector< PCNode * > currentLeafOrder() const
Definition: PCTree.h:538
ogdf::pc_tree::PCTree::Observer::nodeDeleted
virtual void nodeDeleted([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *toBeDeleted)
Definition: PCTree.h:666
ogdf::pc_tree::PCTree::NextFullLeaf
Definition: PCTree.h:606
ogdf::pc_tree::PCTree::FullLeafIter
std::function< std::function< PCNode *()>()> FullLeafIter
Definition: PCTree.h:622
PCTreeForest.h
PCTreeForests contain multiple PCTrees that can be merged with each other.
ogdf::pc_tree::PCTree::Observer::whenCNodeMerged
virtual void whenCNodeMerged([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *tpNeigh, [[maybe_unused]] bool tpNeighSiblingsFlipped, [[maybe_unused]] PCNode *fullNeigh, [[maybe_unused]] PCNode *fullOuterChild)
Definition: PCTree.h:652
ogdf::pc_tree::PCTreeRegistry::keyToIndex
static int keyToIndex(PCNode *key)
Returns the index of key.
Definition: PCTree.h:700
ogdf::pc_tree::PCTree::Observer::onNodeCreate
virtual void onNodeCreate([[maybe_unused]] PCNode *node)
Definition: PCTree.h:628
ogdf::pc_tree::PCTree::PCTree
PCTree()
Constructs a new PCTree.
Definition: PCTree.h:150
ogdf::pc_tree::uid_utils::compareNodesByID
bool compareNodesByID(PCNode *a, PCNode *b)
Sort nodes by ascending index.
ogdf::pc_tree::PCTree::NextFullLeaf::NextFullLeaf
NextFullLeaf(It it, It an_end)
Definition: PCTree.h:610
ogdf::pc_tree::PCTree::Observer::onApexMoved
virtual void onApexMoved([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *apexCandidate, [[maybe_unused]] PCNode *central, [[maybe_unused]] PCNode *parent)
Definition: PCTree.h:662
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::pc_tree::PCTree::Observer::whenPNodeMerged
virtual void whenPNodeMerged([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *tpNeigh, [[maybe_unused]] PCNode *tpPred, [[maybe_unused]] PCNode *fullNeigh)
Definition: PCTree.h:649
ogdf::pc_tree::PCTree::currentLeafOrder
void currentLeafOrder(Container &container) const
Store the order of leaves currently represented by this tree in container.
Definition: PCTree.h:529
ogdf::pc_tree::PCTree::getCNodeCount
size_t getCNodeCount() const
Definition: PCTree.h:510
ogdf::pc_tree::PCTree::mergeLeaves
PCNode * mergeLeaves(const std::vector< PCNode * > &consecutiveLeaves, bool assumeConsecutive=false)
Merge multiple leaves into a single one and return it.
Definition: PCTree.h:237
ogdf::pc_tree::PCTree::possibleOrders
R possibleOrders() const
Calculate the number of cyclic orders represented by this tree.
Definition: PCTree.h:564
ogdf::pc_tree::PCTree::Observer::terminalPathFound
virtual void terminalPathFound([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *apex, [[maybe_unused]] PCNode *apexTPPred2, [[maybe_unused]] int terminalPathLength)
Definition: PCTree.h:637