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>
35 #include <ogdf/basic/basic.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 
53 namespace ogdf {
54 class GraphAttributes;
55 } // namespace ogdf
56 
57 namespace ogdf::pc_tree {
62 OGDF_EXPORT bool isTrivialRestriction(int restSize, int leafCount);
63 
64 OGDF_EXPORT int factorial(int n);
65 
66 #ifdef OGDF_DEBUG
67 
75 #endif
76 
80 namespace uid_utils {
84 OGDF_EXPORT void nodeToID(std::ostream& os, PCNode* n, int pos);
85 
89 OGDF_EXPORT void nodeToPosition(std::ostream& os, PCNode* n, int pos);
90 
94 OGDF_EXPORT void leafToID(std::ostream& os, PCNode* n, int pos);
95 
99 OGDF_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 
126 public:
127  struct Observer; // pre-declaration
128 
129 private:
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 
154 public:
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 
199 public:
203 
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) {
260  OGDF_ASSERT(begin != end);
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 
293  PCNode* setRoot(PCNode* newRoot);
294 
301  PCNode* changeRoot(PCNode* newRoot);
302 
307  PCNodeType changeNodeType(PCNode* node, PCNodeType newType);
308 
315  void insertTree(PCNode* at, PCTree* tree);
316 
317 private:
318  void unregisterNode(PCNode* node);
319 
320  void registerNode(PCNode* node);
321 
323 
324 public:
328 
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
369  if (isTrivialRestriction(end - begin)) {
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 
386  void resetTempData() {
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 
438  bool makeFullNodesConsecutive();
439 
440 private:
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 
445  bool findTerminalPath();
446 
447  void updateSingletonTerminalPath();
448 
449  PCNode* createCentralNode();
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 
459  bool checkTPPartialCNode(PCNode* node);
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 
475 public:
479 
486  bool intersect(PCTree& other, PCTreeNodeArray<PCNode*>& mapping);
487 
488 private:
489  bool findNodeRestrictions(PCTree& applyTo, PCTreeNodeArray<PCNode*>& mapping,
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 
500 public:
504  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 
560  void getTree(ogdf::Graph& tree, ogdf::GraphAttributes* g_a,
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 =
602  std::stringstream sb;
603  uniqueID(sb, printNode, compareNodes);
604  return sb.str();
605  }
606 
608 
609 public:
613  template<typename It>
615  struct NextFullLeaf {
616  It m_it;
617  It m_end;
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 
709 int PCTreeRegistry::keyToIndex(PCNode* key) { return key->index(); }
710 
711 }
ogdf::pc_tree::PCTree::NextFullLeaf::operator()
PCNode * operator()()
Definition: PCTree.h:621
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::GraphAttributes
Stores additional attributes of a graph (like layout information).
Definition: GraphAttributes.h:72
ogdf::RegisteredArray
Dynamic arrays indexed with arbitrary keys.
Definition: RegisteredArray.h:817
ogdf::pc_tree::PCNodeType::CNode
@ CNode
ogdf::pc_tree::PCTree::getPNodeCount
size_t getPNodeCount() const
Definition: PCTree.h:517
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:124
ogdf::pc_tree::FilteringPCTreeDFS
FilteringPCTreeWalk< true > FilteringPCTreeDFS
Definition: PCTreeIterators.h:223
ogdf::pc_tree::PCNode::index
size_t index() const
Definition: PCNode.h:452
ogdf::pc_tree::PCTree::resetTempData
void resetTempData()
Reset all makeConsecutive()-related temporary information, especially which leaves are full (should b...
Definition: PCTree.h:386
ogdf::pc_tree::PCTree::addObserver
std::list< Observer * >::const_iterator addObserver(Observer *observer)
Definition: PCTree.h:697
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::pc_tree::PCTree::getForest
PCTreeForest * getForest() const
The PCTreeForest this PCTree belongs to, or nullptr.
Definition: PCTree.h:508
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:336
ogdf::pc_tree
Definition: NodePCRotation.h:47
OGDF_HEAVY_ASSERT
#define OGDF_HEAVY_ASSERT(expr)
Assert condition expr when using heavy debugging. See OGDF_ASSERT.
Definition: basic.h:55
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:118
ogdf::pc_tree::PCTree::Observer::makeConsecutiveDone
virtual void makeConsecutiveDone([[maybe_unused]] PCTree &tree, [[maybe_unused]] Stage stage, [[maybe_unused]] bool success)
Definition: PCTree.h:668
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:218
ogdf::pc_tree::PCTree::innerNodes
FilteringPCTreeDFS innerNodes() const
An iterable through all inner (non-leaf) nodes of this PCTree.
Definition: PCTree.h:532
ogdf::pc_tree::PCTreeRegistry
A registry that allows labelling the nodes of a PC-tree.
Definition: PCRegistry.h:44
ogdf::pc_tree::PCTree::m_leaves
IntrusiveList< PCNode > m_leaves
Definition: PCTree.h:136
ogdf::pc_tree::PCTree::Observer::centralCreated
virtual void centralCreated([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *central)
Definition: PCTree.h:649
ogdf::pc_tree::PCTree::makeConsecutive
bool makeConsecutive(const std::vector< PCNode * > &consecutiveLeaves)
Definition: PCTree.h:340
ogdf::pc_tree::PCNode::isLeaf
bool isLeaf() const
Definition: PCNode.h:310
ogdf::pc_tree::PCTreeForest::m_nodeArrayRegistry
PCTreeRegistry m_nodeArrayRegistry
Definition: PCTreeForest.h:70
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:634
ogdf::pc_tree::PCNodeType
PCNodeType
Definition: PCEnum.h:43
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:164
ogdf::pc_tree::PCTree::Observer::afterMerge
virtual void afterMerge([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *successor, [[maybe_unused]] PCNode *mergedNode)
Definition: PCTree.h:655
ogdf::pc_tree::IntrusiveList::size
size_t size() const
Definition: IntrusiveList.h:99
ogdf::pc_tree::PCTree::Observer::fullNodeSplit
virtual void fullNodeSplit([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *fullNode)
Definition: PCTree.h:665
ogdf::pc_tree::FilteringPCTreeWalk
A DFS or BFS through a PCTree.
Definition: PCTreeIterators.h:132
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:401
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:598
ogdf::pc_tree::PCNode::setLabel
void setLabel(NodeLabel l)
Definition: PCNode.h:380
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:642
ogdf::pc_tree::IntrusiveList
Definition: IntrusiveList.h:42
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:59
ogdf::pc_tree::PCTree::removeObserver
void removeObserver(Observer *observer)
Definition: PCTree.h:704
backward::Color::type
type
Definition: backward.hpp:1716
ogdf::pc_tree::PCTree::m_observers
std::list< Observer * > m_observers
Definition: PCTree.h:152
ogdf::pc_tree::NodeLabel::Full
@ Full
ogdf::pc_tree::PCTree::getLeafCount
size_t getLeafCount() const
Definition: PCTree.h:515
ogdf::pc_tree::PCTree::Observer::nodeReplaced
virtual void nodeReplaced([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *replaced, [[maybe_unused]] PCNode *replacement)
Definition: PCTree.h:677
ogdf::pc_tree::PCTree::LoggingObserver
Definition: PCTree.h:681
ogdf::pc_tree::isTrivialRestriction
bool isTrivialRestriction(int restSize, int leafCount)
ogdf::pc_tree::PCTree::NextFullLeaf::m_end
It m_end
Definition: PCTree.h:617
ogdf::pc_tree::PCTree::Observer::Stage
Stage
Definition: PCTree.h:635
ogdf::pc_tree::factorial
int factorial(int n)
Returns n!.
Definition: Math.h:147
PCRegistry.h
A registry that allows labelling the nodes of a PC-tree.
config_autogen.h
ogdf::pc_tree::PCTree::getLeaves
const IntrusiveList< PCNode > & getLeaves() const
Definition: PCTree.h:513
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
ogdf::pc_tree::PCTree::NextFullLeaf::m_it
It m_it
Definition: PCTree.h:616
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:417
ogdf::pc_tree::PCTree::removeObserver
void removeObserver(std::list< Observer * >::const_iterator it)
Definition: PCTree.h:702
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:526
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:521
ogdf::pc_tree::PCTreeForest::m_timestamp
size_t m_timestamp
Definition: PCTreeForest.h:69
ogdf::pc_tree::PCNode
A node in a PC-tree that is either a P-node, C-node or leaf.
Definition: PCNode.h:62
ogdf::pc_tree::PCTree::allNodes
FilteringPCTreeDFS allNodes() const
An iterable through all nodes of this PCTree.
Definition: PCTree.h:529
PCNode.h
A node in a PC-tree that is either a P-node, C-node or leaf.
basic.h
Basic declarations, included by all source files.
ogdf::pc_tree::PCTree::Observer::beforeMerge
virtual void beforeMerge([[maybe_unused]] PCTree &tree, [[maybe_unused]] int count, [[maybe_unused]] PCNode *tpNeigh)
Definition: PCTree.h:652
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:352
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:259
ogdf::pc_tree::PCTree::Observer::makeConsecutiveCalled
virtual void makeConsecutiveCalled([[maybe_unused]] PCTree &tree, [[maybe_unused]] FullLeafIter consecutiveLeaves)
Definition: PCTree.h:639
ogdf::pc_tree::PCTree::currentLeafOrder
std::vector< PCNode * > currentLeafOrder() const
Definition: PCTree.h:547
ogdf::pc_tree::PCTree::Observer::nodeDeleted
virtual void nodeDeleted([[maybe_unused]] PCTree &tree, [[maybe_unused]] PCNode *toBeDeleted)
Definition: PCTree.h:675
ogdf::pc_tree::PCTree::NextFullLeaf
Definition: PCTree.h:615
ogdf::pc_tree::PCTree::FullLeafIter
std::function< std::function< PCNode *()>()> FullLeafIter
Definition: PCTree.h:631
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:661
ogdf::pc_tree::PCTreeRegistry::keyToIndex
static int keyToIndex(PCNode *key)
Returns the index of key.
Definition: PCTree.h:709
ogdf::pc_tree::PCTree::Observer::onNodeCreate
virtual void onNodeCreate([[maybe_unused]] PCNode *node)
Definition: PCTree.h:637
ogdf::pc_tree::PCTree::PCTree
PCTree()
Constructs a new PCTree.
Definition: PCTree.h:159
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:619
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:671
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
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:658
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:538
ogdf::pc_tree::PCTree::getCNodeCount
size_t getCNodeCount() const
Definition: PCTree.h:519
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:246
ogdf::pc_tree::PCTree::possibleOrders
R possibleOrders() const
Calculate the number of cyclic orders represented by this tree.
Definition: PCTree.h:573
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:646