Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ClusterGraph.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/Graph.h>
36 #include <ogdf/basic/GraphList.h>
37 #include <ogdf/basic/List.h>
38 #include <ogdf/basic/Observer.h>
40 #include <ogdf/basic/SList.h>
41 #include <ogdf/basic/basic.h>
42 #include <ogdf/basic/comparer.h>
43 #include <ogdf/basic/memory.h>
44 
45 #include <functional>
46 #include <iosfwd>
47 #include <memory>
48 #include <utility>
49 
50 namespace ogdf {
51 
52 class OGDF_EXPORT ClusterElement; // IWYU pragma: keep
53 class OGDF_EXPORT ClusterGraph; // IWYU pragma: keep
54 class OGDF_EXPORT ClusterGraphObserver; // IWYU pragma: keep
55 
57 
59 
63  friend class ClusterGraph;
65 
66  int m_id;
67  int m_depth;
68 
69 public:
75 
79 
82 
84 
88 
90 
91 private:
96 
97 #ifdef OGDF_DEBUG
98  // we store the graph containing this cluster for debugging purposes only
100 #endif
101 
102 
104  List<cluster>& getChildren() { return children; }
105 
107  List<node>& getNodes() { return nodes; }
108 
110  List<adjEntry>& getAdjEntries() { return adjEntries; }
111 
113 
116  void getClusterInducedNodes(List<node>& clusterNodes);
117 
118  void getClusterInducedNodes(NodeArray<bool>& clusterNode, int& num);
119 
120 public:
122 #ifdef OGDF_DEBUG
123  ClusterElement(const ClusterGraph* pClusterGraph, int id)
124  : m_id(id)
125  , m_depth(0)
126  , m_parent(nullptr)
127  , m_pPrev(nullptr)
128  , m_pNext(nullptr)
129  , m_pClusterGraph(pClusterGraph) { }
130 #else
131  explicit ClusterElement(int id)
132  : m_id(id), m_depth(0), m_parent(nullptr), m_pPrev(nullptr), m_pNext(nullptr) { }
133 #endif
134 
135 
139 
141 #ifdef OGDF_DEBUG
142  const ClusterGraph* graphOf() const { return m_pClusterGraph; }
143 #endif
144 
145 
147  int index() const { return m_id; }
148 
150  int depth() const { return m_depth; }
151 
153  cluster parent() { return m_parent; }
154 
156  cluster succ() const { return static_cast<cluster>(m_next); }
157 
159  cluster pred() const { return static_cast<cluster>(m_prev); }
160 
162  cluster pSucc() const { return m_pNext; }
163 
165  cluster pPred() const { return m_pPrev; }
166 
168 
171  void getClusterNodes(List<node>& clusterNodes) {
172  clusterNodes.clear();
173  getClusterInducedNodes(clusterNodes);
174  }
175 
177 
182  int getClusterNodes(NodeArray<bool>& clusterNode) {
183  int num = 0;
184  getClusterInducedNodes(clusterNode, num);
185  return num;
186  }
187 
189 
194  bool isDescendant(ClusterElement* child, bool allow_equal = false) {
195  OGDF_ASSERT(child != nullptr);
196  if (!allow_equal) {
197  child = child->parent();
198  }
199  while (child != this) {
200  if (child == nullptr) {
201  return false;
202  }
203  child = child->parent();
204  }
205  return true;
206  }
207 
209 
213 
216  ListConstIterator<ClusterElement*> cBegin() const { return children.begin(); }
217 
219  ListConstIterator<ClusterElement*> crBegin() const { return children.rbegin(); }
220 
222  int cCount() { return children.size(); }
223 
225  ListConstIterator<node> nBegin() const { return nodes.begin(); }
226 
228  int nCount() { return nodes.size(); }
229 
231  ListConstIterator<adjEntry> firstAdj() const { return adjEntries.begin(); }
232 
234  ListConstIterator<adjEntry> lastAdj() const { return adjEntries.rbegin(); }
235 
237 
239  static int compare(const ClusterElement& x, const ClusterElement& y) { return x.m_id - y.m_id; }
241 
243 };
244 
247 
250 #define forall_cluster_adj(adj, c) \
251  for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->firstAdj(); \
252  ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var, (adj)); \
253  ogdf_loop_var = ogdf_loop_var.succ())
254 
257 #define forall_cluster_rev_adj(adj, c) \
258  for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->lastAdj(); \
259  ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var, (adj)); \
260  ogdf_loop_var = ogdf_loop_var.pred())
261 
264 #define forall_cluster_adj_edges(e, c) \
265  for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->firstAdj(); \
266  ogdf::test_forall_adj_edges_of_cluster(ogdf_loop_var, (e)); \
267  ogdf_loop_var = ogdf_loop_var.succ())
268 
270  if (it.valid()) {
271  adj = (*it);
272  return true;
273  } else {
274  return false;
275  }
276 }
277 
279  adjEntry adj = (*it);
280  if (adj) {
281  e = adj->theEdge();
282  return true;
283  } else {
284  return false;
285  }
286 }
287 
289  if (adj) {
290  e = adj->theEdge();
291  return true;
292  } else {
293  return false;
294  }
295 }
296 
299 #define forall_clusters(c, C) for ((c) = (C).firstCluster(); (c); (c) = (c)->succ())
300 
303 #define forall_postOrderClusters(c, C) \
304  for ((c) = (C).firstPostOrderCluster(); (c); (c) = (c)->pSucc())
305 
307 
309 
310 template<typename Value, bool WithDefault>
311 class ClusterArrayBase; // IWYU pragma: keep
312 
313 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) ClusterArrayBase<v, c>
315 #undef OGDF_DECL_REG_ARRAY_TYPE
316 
326 class OGDF_EXPORT ClusterGraphObserver : public Observer<ClusterGraph, ClusterGraphObserver> {
327 public:
328  ClusterGraphObserver() = default;
329 
330  explicit ClusterGraphObserver(const ClusterGraph* CG) { reregister(CG); }
331 
332  virtual void clusterDeleted(cluster v) = 0;
333  virtual void clusterAdded(cluster v) = 0;
334  virtual void clustersCleared() = 0;
335 
336  const ClusterGraph* getGraph() const { return getObserved(); }
337 };
338 
340 
347  : public GraphObserver, // to get updates when graph nodes/edges added/removed
348  public Observable<ClusterGraphObserver, ClusterGraph>, // to publish updates when clusters added/removed
349  public ClusterGraphRegistry // for ClusterArrays
350 {
351  int m_clusterIdCount = 0;
352 
353  mutable cluster m_postOrderStart = nullptr;
354  cluster m_rootCluster = nullptr;
355 
356  bool m_adjAvailable = false;
357  bool m_allowEmptyClusters =
358  true;
359 
363 
364 public:
370 
374 
376 
381 
385 
387 
388 
390 
393  ClusterGraph();
394 
396 
399  explicit ClusterGraph(const Graph& G);
400 
402 
406  ClusterGraph(const ClusterGraph& C);
407 
409 
412  ClusterGraph(const ClusterGraph& C, Graph& G);
413 
415 
419  ClusterGraph(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
420  NodeArray<node>& originalNodeTable);
421 
423 
428  ClusterGraph(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
429  NodeArray<node>& originalNodeTable, EdgeArray<edge>& edgeCopy);
430 
432  virtual ~ClusterGraph();
433 
437 
440  cluster rootCluster() const { return m_rootCluster; }
441 
443  int numberOfClusters() const { return clusters.size(); }
444 
446  int maxClusterIndex() const { return m_clusterIdCount - 1; }
447 
449  inline cluster clusterOf(node v) const { return m_nodeMap[v]; }
450 
452  //should be called instead of direct c->depth call to assure
453  //valid depth
454  int& clusterDepth(cluster c) const {
455  // updateDepth must be set to true if depth info shall be used
456  OGDF_ASSERT(m_updateDepth);
457 
458  //initialize depth at first call
459  if (!m_depthUpToDate) {
460  computeSubTreeDepth(rootCluster());
461  }
462  OGDF_ASSERT(c->depth() != 0);
463  return c->m_depth;
464  }
465 
467  cluster firstCluster() const { return clusters.head(); }
468 
470  cluster lastCluster() const { return clusters.tail(); }
471 
474  if (!m_postOrderStart) {
475  postOrder();
476  }
477  return m_postOrderStart;
478  }
479 
481  template<class CLUSTERLIST>
482  void allClusters(CLUSTERLIST& clusterList) const {
483  clusterList.clear();
484  for (cluster c : clusters) {
485  clusterList.pushBack(c);
486  }
487  }
488 
490 
493 
496  void clear();
497 
499  void init(const Graph& G);
500 
502  void clearClusterTree(cluster C);
503 
505  cluster newCluster(cluster parent, int id = -1);
506 
508  cluster createEmptyCluster(const cluster parent = nullptr, int clusterId = -1);
509 
511 
519  cluster createCluster(const SList<node>& nodes, const cluster parent = nullptr);
520 
522 
526  void delCluster(cluster c);
527 
529  void moveCluster(cluster c, cluster newParent);
530 
531 
533  void reassignNode(node v, cluster c);
534 
536  //inserted mainly for use in gmlparser.
537  void reInit(Graph& G) { reinitGraph(G); }
538 
540  void copyClusterTree(
541  const ClusterGraph& C, const Graph& G, ClusterArray<cluster>& originalClusterTable,
542  std::function<node(node)> nodeMap = [](node v) { return v; });
543 
545  template<class NODELIST>
546  void collapse(NODELIST& nodes, Graph& G) {
547  OGDF_ASSERT(&G == &constGraph());
548  m_adjAvailable = false;
549 
550  m_postOrderStart = nullptr;
551  node v = nodes.popFrontRet();
552  while (!nodes.empty()) {
553  node w = nodes.popFrontRet();
554  adjEntry adj = w->firstAdj();
555  while (adj != nullptr) {
556  adjEntry succ = adj->succ();
557  edge e = adj->theEdge();
558  if (e->source() == v || e->target() == v) {
559  G.delEdge(e);
560  } else if (e->source() == w) {
561  G.moveSource(e, v);
562  } else {
563  G.moveTarget(e, v);
564  }
565  adj = succ;
566  }
567  //because nodes can already be unassigned (they are always
568  //unassigned if deleted), we have to check this
569 #if 0
570  if (m_nodeMap[w])
571  {
572  cluster c = m_nodeMap[w];
573  c->m_entries.del(m_itMap[w]);
574  }
575  removeNodeAssignment(w);
576 #endif
577  G.delNode(w);
578  }
579  }
580 
582 
583 
587 
596  cluster chooseCluster(
597  std::function<bool(cluster)> includeCluster = [](cluster) { return true; },
598  bool isFastTest = true) const;
599 
601  void setUpdateDepth(bool b) const {
602  m_updateDepth = b;
603  //make sure that depth cant be used anymore
604  //(even if it may still be valid a little while)
605  if (!b) {
606  m_depthUpToDate = false;
607  }
608  }
609 
611  void pullUpSubTree(cluster c);
612 
614  //maybe later we should provide a permanent depth member update
615  int treeDepth() const;
616 
618  void computeSubTreeDepth(cluster c) const;
619 
621  cluster commonCluster(SList<node>& nodes);
622 
624 
628  cluster c1, c2;
629  return commonClusterLastAncestors(v, w, c1, c2);
630  }
631 
634  List<cluster> eL;
635  return commonClusterAncestorsPath(v, w, c1, c2, eL);
636  }
637 
639 
643  cluster c1, c2;
644  return commonClusterAncestorsPath(v, w, c1, c2, eL);
645  }
646 
648  cluster commonClusterAncestorsPath(node v, node w, cluster& c1, cluster& c2,
649  List<cluster>& eL) const;
650 
652 
659  void emptyClusters(SList<cluster>& emptyCluster, SList<cluster>* checkCluster = nullptr);
660 
662  inline bool emptyOnNodeDelete(cluster c) //virtual?
663  {
664 #if 0
665  if (!c) {
666  return false; //Allows easy use in loops
667  }
668 #endif
669  return c->nCount() == 1 && c->cCount() == 0;
670  }
671 
673  inline bool emptyOnClusterDelete(cluster c) //virtual?
674  {
675 #if 0
676  if (!c) {
677  return false; //Allows easy use in loops
678  }
679 #endif
680  return c->nCount() == 0 && c->cCount() == 1;
681  }
682 
684 
687 
690  template<class EDGELIST>
691  void adjEdges(cluster c, EDGELIST& edges) const {
692  edges.clear();
693 
694  if (m_adjAvailable) {
695  edge e;
697  edges.pushBack(e);
698  }
699  }
700  }
701 
703  template<class ADJLIST>
704  void adjEntries(cluster c, ADJLIST& entries) const {
705  entries.clear();
706  if (m_adjAvailable) {
707  for (adjEntry adj : c->adjEntries) {
708  entries.pushBack(adj);
709  }
710  }
711  }
712 
714  template<class LISTITERATOR>
715  void makeAdjEntries(cluster c, LISTITERATOR start) {
716  c->adjEntries.clear();
717  LISTITERATOR its;
718  for (its = start; its.valid(); its++) {
719  adjEntry adj = (*its);
720  c->adjEntries.pushBack(adj);
721  }
722  }
723 
725  bool adjAvailable() const { return m_adjAvailable; }
726 
728  void adjAvailable(bool val) { m_adjAvailable = val; }
729 
731 
734 
737 
742  bool representsCombEmbedding() const;
743 
745 
753  bool representsConnectedCombEmbedding() const;
754 
755 #ifdef OGDF_DEBUG
756  void consistencyCheck() const;
758 #endif
759 
761 
766 
768  static inline int keyToIndex(cluster key) { return key->index(); }
769 
770  bool isKeyAssociated(cluster key) const {
771  if (key == nullptr) {
772  return false;
773  }
774 #ifdef OGDF_DEBUG
775  if (key->graphOf() == this) {
776  OGDF_ASSERT(keyToIndex(key) < this->getArraySize());
777  return true;
778  } else {
779  return false;
780  }
781 #else
782  return true;
783 #endif
784  }
785 
786  int calculateArraySize(int add) const { return calculateTableSize(m_clusterIdCount + add); }
787 
788  int maxKeyIndex() const { return (m_clusterIdCount)-1; }
789 
790  cluster_iterator begin() const { return clusters.begin(); }
791 
792  cluster_iterator end() const { return clusters.end(); }
793 
795 
798 
801  operator const Graph&() const { return *getGraph(); }
802 
804  const Graph& constGraph() const { return *getGraph(); }
805 
807  ClusterGraph& operator=(const ClusterGraph& C);
808 
810 
811 protected:
812  mutable std::unique_ptr<ClusterArray<int>> m_lcaSearch;
813  mutable int m_lcaNumber = 0;
814  mutable std::unique_ptr<ClusterArray<cluster>> m_vAncestor;
815  mutable std::unique_ptr<ClusterArray<cluster>> m_wAncestor;
816 
817  mutable bool m_updateDepth = false;
818  mutable bool m_depthUpToDate = false;
819 
822  cluster doCreateCluster(const SList<node>& nodes, const cluster parent, int clusterId = -1);
823 
826  cluster doCreateCluster(const SList<node>& nodes, SList<cluster>& emptyCluster,
827  const cluster parent, int clusterId = -1);
828 
830  void doClear();
831 
833  void copyLCA(const ClusterGraph& C);
834  //int m_treeDepth; //should be implemented and updated in operations?
835 
837  //we assume that c is inserted via pushback in newparent->children
838  void updatePostOrder(cluster c, cluster oldParent, cluster newParent);
839 
841  cluster postOrderPredecessor(cluster c) const;
842 
844  cluster leftMostCluster(cluster c) const;
845 
848 
850  void nodeDeleted(node v) override;
851 
853  void nodeAdded(node v) override { assignNode(v, rootCluster()); }
854 
856  void edgeDeleted(edge /* e */) override { }
857 
859  void edgeAdded(edge /* e */) override { }
860 
862  void cleared() override {
863  //we don't want a complete clear, as the graph still exists
864  //and can be updated from input stream
865  clear();
866  }
867 
868  void registrationChanged(const Graph* newG) override;
869 
871 
872 private:
874  template<typename T>
875  inline void fillEmptyClusters(SList<cluster>& emptyCluster, const T& clusterList) const {
876  emptyCluster.clear();
877 
878  for (cluster cc : clusterList) {
879  if (cc->cCount() + cc->nCount() == 0 && cc != rootCluster()) { // we dont add rootcluster
880  emptyCluster.pushBack(cc);
881  }
882  }
883  }
884 
887  m_adjAvailable = false;
888  for (auto child : c->getChildren()) {
889  clearClusterTree(child, attached);
890  }
891  }
892 
894  void assignNode(node v, cluster C);
895 
897  void unassignNode(node v);
898 
902  if (m_nodeMap[v]) //iff == 0, itmap == 0 !!?
903  {
904  cluster c2 = m_nodeMap[v];
905  c2->nodes.del(m_itMap[v]);
906  m_nodeMap[v] = nullptr;
907  m_itMap[v] = ListIterator<node>();
908  }
909  }
910 
913  void shallowCopy(const ClusterGraph& C);
914 
917  void deepCopy(const ClusterGraph& C, Graph& G);
918 
921  void deepCopy(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
922  NodeArray<node>& originalNodeTable);
923 
927  void deepCopy(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
928  NodeArray<node>& originalNodeTable, EdgeArray<edge>& edgeCopy);
929 
930 
931  void clearClusterTree(cluster c, List<node>& attached);
932 
933  void initGraph(const Graph& G);
934 
936  void reinitGraph(const Graph& G);
937 
939  cluster newCluster(int id);
940 
942  cluster newCluster();
943 
945  void postOrder() const;
946 
947 #ifdef OGDF_DEBUG
948  void checkPostOrder() const;
950 #endif
951 
952  void postOrder(cluster c, SListPure<cluster>& S) const;
953 };
954 
956 template<class Value, bool WithDefault>
957 class ClusterArrayBase : public RegisteredArray<ClusterGraph, Value, WithDefault> {
959 
960 public:
961  using RA::RA;
962 
964  ClusterArrayBase() = default;
965 
967  ClusterArrayBase(const ClusterGraph& C, const Value& def, int size) : RA(C, def) {
968  RA::resize(size, true);
969  };
970 
972  ClusterGraph* graphOf() const { return RA::registeredAt(); }
973 };
974 
975 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, cluster c);
976 
978 
990 OGDF_EXPORT void planarizeClusterBorderCrossings(const ClusterGraph& CG, Graph& G,
991  EdgeArray<List<std::pair<adjEntry, cluster>>>* subdivisions,
992  const std::function<edge(edge)>& translate);
993 
994 }
ogdf::RegistryBase
Abstract base class for registries.
Definition: RegisteredArray.h:104
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::ClusterGraph::nodeAdded
void nodeAdded(node v) override
Implementation of inherited method: Updates data if node added.
Definition: ClusterGraph.h:853
ogdf::RegisteredArray
Dynamic arrays indexed with arbitrary keys.
Definition: RegisteredArray.h:817
OGDF_DECL_REG_ARRAY
#define OGDF_DECL_REG_ARRAY(NAME)
Definition: RegisteredArray.h:969
ogdf::internal::GraphList< GraphObject >::size
int size() const
Returns the size of the list.
Definition: GraphList.h:89
ogdf::ClusterGraph::m_lcaSearch
std::unique_ptr< ClusterArray< int > > m_lcaSearch
Used to save last search run number for commoncluster.
Definition: ClusterGraph.h:812
Graph.h
Includes declaration of graph class.
ogdf::ClusterArrayBase::ClusterArrayBase
ClusterArrayBase(const ClusterGraph &C, const Value &def, int size)
Creates a new cluster array with initial capacity size.
Definition: ClusterGraph.h:967
ogdf::internal::GraphList< GraphObject >::tail
GraphObject * tail() const
Returns the last element in the list.
Definition: GraphList.h:327
ogdf::ClusterGraphObserver::getGraph
const ClusterGraph * getGraph() const
Definition: ClusterGraph.h:336
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::internal::GraphIteratorBase
Definition: graph_iterators.h:45
ogdf::ClusterGraph::lastCluster
cluster lastCluster() const
Returns the last cluster in the list of all cluster.
Definition: ClusterGraph.h:470
ogdf::ClusterGraph::makeAdjEntries
void makeAdjEntries(cluster c, LISTITERATOR start)
Computes the adjacency entry list for cluster c.
Definition: ClusterGraph.h:715
ogdf::test_forall_adj_edges_of_cluster
bool test_forall_adj_edges_of_cluster(ListConstIterator< adjEntry > &it, edge &e)
Definition: ClusterGraph.h:278
ogdf::RegisteredArray::RA
typename std::conditional< WithDefault, internal::RegisteredArrayWithDefault< Registry, Value >, internal::RegisteredArrayWithoutDefault< Registry, Value > >::type RA
Definition: RegisteredArray.h:822
ogdf::ClusterGraph::m_nodeMap
NodeArray< cluster > m_nodeMap
Defines if empty clusters are deleted immediately if generated by operations.
Definition: ClusterGraph.h:360
ogdf::internal::GraphElement
The base class for objects used by (hyper)graphs.
Definition: GraphList.h:60
ogdf::EdgeArray
internal::EdgeArrayBase2< Value, WithDefault > EdgeArray
RegisteredArray for labeling the edges in a Graph with an arbitrary Value.
Definition: Graph_d.h:745
OGDF_AUGMENT_COMPARER
#define OGDF_AUGMENT_COMPARER(type)
Add this macro to your class to turn it into a full comparer.
Definition: comparer.h:183
ogdf::ClusterGraph::constGraph
const Graph & constGraph() const
Returns a reference to the underlying graph.
Definition: ClusterGraph.h:804
ogdf::ClusterArrayBase
RegisteredArray for labeling the clusters of a ClusterGraph.
Definition: ClusterGraph.h:311
ogdf::ClusterElement::getClusterNodes
void getClusterNodes(List< node > &clusterNodes)
Returns the list of nodes in the cluster, i.e., all nodes in the subtree rooted at this cluster.
Definition: ClusterGraph.h:171
ogdf::ClusterGraph::firstCluster
cluster firstCluster() const
Returns the first cluster in the list of all clusters.
Definition: ClusterGraph.h:467
Observer.h
Simple, safe base classes for C++ observables and observers.
ogdf::ClusterGraph::setUpdateDepth
void setUpdateDepth(bool b) const
Turns automatic update of node depth values on or off.
Definition: ClusterGraph.h:601
forall_cluster_adj_edges
#define forall_cluster_adj_edges(e, c)
Iterates over all outgoing edges.
Definition: ClusterGraph.h:264
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:845
ogdf::ClusterGraph::emptyOnNodeDelete
bool emptyOnNodeDelete(cluster c)
Returns true if cluster c has only one node and no children.
Definition: ClusterGraph.h:662
ogdf::ClusterElement::getNodes
List< node > & getNodes()
Provides access to the encapsulated list of nodes (for friends of ClusterElement).
Definition: ClusterGraph.h:107
ogdf::ClusterElement::cCount
int cCount()
Returns the number of child clusters.
Definition: ClusterGraph.h:222
ogdf::ListIteratorBase::valid
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:153
ogdf::ClusterGraph::maxClusterIndex
int maxClusterIndex() const
Returns the maximal used cluster index.
Definition: ClusterGraph.h:446
ogdf::ClusterGraph::edgeAdded
void edgeAdded(edge) override
Implementation of inherited method: Updates data if edge added.
Definition: ClusterGraph.h:859
ogdf::ClusterElement::pred
cluster pred() const
Returns the predecessor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:159
ogdf::internal::GraphObjectContainer
Public read-only interface for lists of graph objects.
Definition: GraphList.h:410
ogdf::ClusterGraph::removeNodeAssignment
void removeNodeAssignment(node v)
Remove the assignment entries for nodes. Checks if node v is currently not assigned.
Definition: ClusterGraph.h:901
ogdf::ClusterElement::m_id
int m_id
The index of this cluster.
Definition: ClusterGraph.h:66
ogdf::ClusterGraphObserver
Abstract base class for cluster graph observers.
Definition: ClusterGraph.h:326
ogdf::ClusterElement::compare
static int compare(const ClusterElement &x, const ClusterElement &y)
Standard Comparer (uses cluster indices).
Definition: ClusterGraph.h:239
ogdf::ClusterElement::pPred
cluster pPred() const
Returns the postorder predecessor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:165
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:85
ogdf::ClusterGraph::m_wAncestor
std::unique_ptr< ClusterArray< cluster > > m_wAncestor
Used to save last search run number for commoncluster.
Definition: ClusterGraph.h:815
ogdf::ClusterGraph::cleared
void cleared() override
Clears cluster data without deleting root when underlying graphs' clear method is called.
Definition: ClusterGraph.h:862
ogdf::ClusterGraph::edgeDeleted
void edgeDeleted(edge) override
Implementation of inherited method: Updates data if edge deleted.
Definition: ClusterGraph.h:856
ogdf::cluster
ClusterElement * cluster
The type of clusters.
Definition: ClusterGraph.h:56
ogdf::ListContainer::rbegin
reverse_iterator rbegin() const
Returns a reverse iterator to the last element in the container.
Definition: List.h:1844
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:142
ogdf::ClusterElement::children
ListContainer< cluster, ClusterElement > children
The container containing the child clusters (children in the cluster tree) of this cluster.
Definition: ClusterGraph.h:81
ogdf::ListContainer::size
int size() const
Returns the number of elements in the container.
Definition: List.h:1850
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:74
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:62
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:160
ogdf::ClusterElement::graphOf
const ClusterGraph * graphOf() const
Definition: ClusterGraph.h:142
ogdf::ClusterElement::m_parent
cluster m_parent
The parent of this cluster.
Definition: ClusterGraph.h:92
ogdf::Observable
Base class for an observable object that can be tracked by multiple Observer objects.
Definition: Observer.h:104
ogdf::ClusterGraph::allClusters
void allClusters(CLUSTERLIST &clusterList) const
Returns the list of all clusters in clusterList.
Definition: ClusterGraph.h:482
ogdf::ClusterGraph::clusters
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
Definition: ClusterGraph.h:384
ogdf::ClusterElement::isDescendant
bool isDescendant(ClusterElement *child, bool allow_equal=false)
Checks whether a cluster child is a descendant (i.e. child, child of a child, ...) of this cluster.
Definition: ClusterGraph.h:194
ogdf::ClusterGraph::adjAvailable
bool adjAvailable() const
Gets the availability status of the adjacency entries.
Definition: ClusterGraph.h:725
ogdf::ClusterGraphObserver::ClusterGraphObserver
ClusterGraphObserver(const ClusterGraph *CG)
Definition: ClusterGraph.h:330
ogdf::ClusterGraph::clusterDepth
int & clusterDepth(cluster c) const
Returns depth of cluster c in cluster tree, starting with root depth 1.
Definition: ClusterGraph.h:454
ogdf::ClusterElement::nCount
int nCount()
Returns the number of child nodes.
Definition: ClusterGraph.h:228
SList.h
Declaration of singly linked lists and iterators.
GraphList.h
Decralation of GraphElement and GraphList classes.
ogdf::AdjElement::succ
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:218
ogdf::ClusterGraph::reInit
void reInit(Graph &G)
Clear cluster info structure, reinitializes with underlying graph G.
Definition: ClusterGraph.h:537
ogdf::ClusterGraph::adjEdges
void adjEdges(cluster c, EDGELIST &edges) const
Returns the list of all edges adjacent to cluster c in edges.
Definition: ClusterGraph.h:691
ogdf::calculateTableSize
int calculateTableSize(int actualCount)
The default growth function for registered arrays.
Definition: RegisteredArray.h:67
RegisteredArray.h
Declaration and implementation of RegisteredArray class.
ogdf::ClusterElement::ClusterElement
ClusterElement(const ClusterGraph *pClusterGraph, int id)
Creates a new cluster element.
Definition: ClusterGraph.h:123
ogdf::ClusterGraph::isKeyAssociated
bool isKeyAssociated(cluster key) const
Definition: ClusterGraph.h:770
ogdf::ClusterGraph::begin
cluster_iterator begin() const
Definition: ClusterGraph.h:790
ogdf::ListContainer::begin
iterator begin() const
Returns an iterator to the first element in the container.
Definition: List.h:1838
ogdf::SListPure
Singly linked lists.
Definition: SList.h:52
ogdf::ClusterElement::succ
cluster succ() const
Returns the successor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:156
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:983
ogdf::ClusterGraph::end
cluster_iterator end() const
Definition: ClusterGraph.h:792
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:398
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:70
ogdf::GraphObserver
Abstract Base class for graph observers.
Definition: Graph_d.h:777
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: DfsMakeBiconnected.h:40
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::ClusterGraph::emptyOnClusterDelete
bool emptyOnClusterDelete(cluster c)
Returns true if cluster c has only one child and no nodes.
Definition: ClusterGraph.h:673
ogdf::internal::GraphList
Lists of graph objects (like nodes, edges, etc.).
Definition: GraphList.h:301
ogdf::planarizeClusterBorderCrossings
void planarizeClusterBorderCrossings(const ClusterGraph &CG, Graph &G, EdgeArray< List< std::pair< adjEntry, cluster >>> *subdivisions, const std::function< edge(edge)> &translate)
Turn cluster borders into cycles of edges and cluster-border-edge-crossings into vertices.
ogdf::ClusterElement::m_pPrev
cluster m_pPrev
The postorder predecessor of this cluster.
Definition: ClusterGraph.h:93
ogdf::ClusterGraph::commonClusterLastAncestors
cluster commonClusterLastAncestors(node v, node w, cluster &c1, cluster &c2) const
Returns the lowest common cluster lca and the highest ancestors on the path to lca.
Definition: ClusterGraph.h:633
ogdf::ClusterElement::getClusterNodes
int getClusterNodes(NodeArray< bool > &clusterNode)
Sets the entry for each node v to true if v is a member of the subgraph induced by the ClusterElement...
Definition: ClusterGraph.h:182
ogdf::ClusterElement::m_depth
int m_depth
The depth of this cluster in the cluster tree.
Definition: ClusterGraph.h:67
ogdf::test_forall_adj_entries_of_cluster
bool test_forall_adj_entries_of_cluster(ListConstIterator< adjEntry > &it, adjEntry &adj)
Definition: ClusterGraph.h:269
ogdf::SList::clear
void clear()
Removes all elements from the list.
Definition: SList.h:984
ogdf::ClusterElement::adjEntries
ListContainer< adjEntry, ClusterElement > adjEntries
The container containing the sorted list of adjacency entries of edges leaving this cluster.
Definition: ClusterGraph.h:87
ogdf::ListContainer
Definition: List.h:1828
ogdf::ClusterElement::depth
int depth() const
Returns the depth of the cluster in the cluster tree.
Definition: ClusterGraph.h:150
ogdf::ClusterElement::lastAdj
ListConstIterator< adjEntry > lastAdj() const
Returns the last adjacency entry in the list of outgoing edges.
Definition: ClusterGraph.h:234
ogdf::ClusterGraph::adjEntries
void adjEntries(cluster c, ADJLIST &entries) const
Returns the list of all adjacency entries adjacent to cluster c in entries.
Definition: ClusterGraph.h:704
ogdf::ClusterGraph::calculateArraySize
int calculateArraySize(int add) const
Definition: ClusterGraph.h:786
ogdf::ClusterGraph::numberOfClusters
int numberOfClusters() const
Returns the number of clusters.
Definition: ClusterGraph.h:443
ogdf::ClusterGraph::rootCluster
cluster rootCluster() const
Returns the root cluster.
Definition: ClusterGraph.h:440
ogdf::internal::GraphList< GraphObject >::begin
iterator begin() const
Returns an iterator to the first element in the container.
Definition: GraphList.h:385
ogdf::ClusterGraph::adjAvailable
void adjAvailable(bool val)
Sets the availability status of the adjacency entries.
Definition: ClusterGraph.h:728
ogdf::graphics::init
void init()
Definition: graphics.h:450
ogdf::internal::GraphList< GraphObject >::head
GraphObject * head() const
Returns the first element in the list.
Definition: GraphList.h:324
ogdf::Observer
Base class for an observer for a single Observable object.
Definition: Observer.h:53
ogdf::ClusterGraph::maxKeyIndex
int maxKeyIndex() const
Definition: ClusterGraph.h:788
ogdf::ClusterElement::m_it
ListIterator< cluster > m_it
The position of this cluster within the children list of its parent.
Definition: ClusterGraph.h:95
ogdf::ClusterGraph::collapse
void collapse(NODELIST &nodes, Graph &G)
Collapses all nodes in the list nodes to the first node; multi-edges are removed.
Definition: ClusterGraph.h:546
basic.h
Basic declarations, included by all source files.
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::ClusterGraph::commonCluster
cluster commonCluster(node v, node w) const
Returns the lowest common cluster of v and w in the cluster tree.
Definition: ClusterGraph.h:627
ogdf::internal::GraphList< GraphObject >::end
iterator end() const
Returns an iterator to the one-past-last element in the container.
Definition: GraphList.h:388
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:286
ogdf::ClusterElement::pSucc
cluster pSucc() const
Returns the postorder successor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:162
ogdf::ClusterElement::nBegin
ListConstIterator< node > nBegin() const
Returns the first element in list of child nodes.
Definition: ClusterGraph.h:225
ogdf::ClusterElement::getChildren
List< cluster > & getChildren()
Provides access to the encapsulated list of children (for friends of ClusterElement).
Definition: ClusterGraph.h:104
ogdf::ClusterElement::m_pClusterGraph
const ClusterGraph * m_pClusterGraph
Definition: ClusterGraph.h:99
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:363
ogdf::ClusterElement::index
int index() const
Returns the (unique) index of the cluster.
Definition: ClusterGraph.h:147
ogdf::ClusterGraph::recurseClearClusterTreeOnChildren
void recurseClearClusterTreeOnChildren(cluster c, List< node > &attached)
Clears children of a cluster, used by recursive clearClusterTree.
Definition: ClusterGraph.h:886
List.h
Declaration of doubly linked lists and iterators.
ogdf::ClusterElement::parent
cluster parent()
Returns the parent of the cluster.
Definition: ClusterGraph.h:153
ogdf::ClusterGraph::clusterOf
cluster clusterOf(node v) const
Returns the cluster to which a node belongs.
Definition: ClusterGraph.h:449
ogdf::ClusterGraph::m_vAncestor
std::unique_ptr< ClusterArray< cluster > > m_vAncestor
Used to save last search run number for commoncluster.
Definition: ClusterGraph.h:814
ogdf::ClusterElement::m_pNext
cluster m_pNext
The postorder successor of this cluster.
Definition: ClusterGraph.h:94
ogdf::ClusterGraph::firstPostOrderCluster
cluster firstPostOrderCluster() const
Returns the first cluster in the list of post ordered clusters.
Definition: ClusterGraph.h:473
ogdf::ClusterElement::cBegin
ListConstIterator< ClusterElement * > cBegin() const
Returns the first element in the list of child clusters.
Definition: ClusterGraph.h:216
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:51
ogdf::ClusterElement::crBegin
ListConstIterator< ClusterElement * > crBegin() const
Returns the last element in the list of child clusters.
Definition: ClusterGraph.h:219
ogdf::ClusterElement::getAdjEntries
List< adjEntry > & getAdjEntries()
Provides access to the encapsulated list of adjacency entries (for friends of ClusterElement).
Definition: ClusterGraph.h:110
ogdf::ClusterArrayBase::graphOf
ClusterGraph * graphOf() const
Returns a pointer to the associated cluster graph.
Definition: ClusterGraph.h:972
ogdf::ClusterElement::nodes
ListContainer< node, ClusterElement > nodes
The container containing the nodes lying (directly) in this cluster.
Definition: ClusterGraph.h:78
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:401
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:346
comparer.h
Declarations for Comparer objects.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
memory.h
Declaration of memory manager for allocating small pieces of memory.
ogdf::ClusterArrayBase::ClusterArrayBase
ClusterArrayBase()=default
Default Constructor.
ogdf::ClusterGraph::keyToIndex
static int keyToIndex(cluster key)
Definition: ClusterGraph.h:768
ogdf::SList::pushBack
SListIterator< E > pushBack(const E &x)
Adds element x at the end of the list.
Definition: SList.h:939
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::ClusterGraph::fillEmptyClusters
void fillEmptyClusters(SList< cluster > &emptyCluster, const T &clusterList) const
Fills emptyCluster with empty, non-root clusters from clusterList.
Definition: ClusterGraph.h:875
ogdf::List::clear
void clear()
Removes all elements from the list.
Definition: List.h:1626
ogdf::ClusterGraph::commonClusterPath
cluster commonClusterPath(node v, node w, List< cluster > &eL) const
Returns lca of v and w and stores corresponding path in eL.
Definition: ClusterGraph.h:642
ogdf::ClusterElement::firstAdj
ListConstIterator< adjEntry > firstAdj() const
Returns the first adjacency entry in the list of outgoing edges.
Definition: ClusterGraph.h:231