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>
37 #include <ogdf/basic/Observer.h>
39 #include <ogdf/basic/SList.h>
40 
41 #include <memory>
42 
43 namespace ogdf {
44 
45 class OGDF_EXPORT ClusterGraph;
46 class OGDF_EXPORT ClusterGraphObserver;
47 class OGDF_EXPORT ClusterElement;
48 
50 
52 
56  friend class ClusterGraph;
58 
59  int m_id;
60  int m_depth;
61 
62 public:
68 
72 
75 
77 
81 
83 
84 private:
89 
90 #ifdef OGDF_DEBUG
91  // we store the graph containing this cluster for debugging purposes only
93 #endif
94 
95 
97  List<cluster>& getChildren() { return children; }
98 
100  List<node>& getNodes() { return nodes; }
101 
103  List<adjEntry>& getAdjEntries() { return adjEntries; }
104 
106 
109  void getClusterInducedNodes(List<node>& clusterNodes);
110 
111  void getClusterInducedNodes(NodeArray<bool>& clusterNode, int& num);
112 
113 public:
115 #ifdef OGDF_DEBUG
116  ClusterElement(const ClusterGraph* pClusterGraph, int id)
117  : m_id(id)
118  , m_depth(0)
119  , m_parent(nullptr)
120  , m_pPrev(nullptr)
121  , m_pNext(nullptr)
122  , m_pClusterGraph(pClusterGraph) { }
123 #else
124  explicit ClusterElement(int id)
125  : m_id(id), m_depth(0), m_parent(nullptr), m_pPrev(nullptr), m_pNext(nullptr) { }
126 #endif
127 
128 
132 
134 #ifdef OGDF_DEBUG
135  const ClusterGraph* graphOf() const { return m_pClusterGraph; }
136 #endif
137 
138 
140  int index() const { return m_id; }
141 
143  int depth() const { return m_depth; }
144 
146  cluster parent() { return m_parent; }
147 
149  cluster succ() const { return static_cast<cluster>(m_next); }
150 
152  cluster pred() const { return static_cast<cluster>(m_prev); }
153 
155  cluster pSucc() const { return m_pNext; }
156 
158  cluster pPred() const { return m_pPrev; }
159 
161 
164  void getClusterNodes(List<node>& clusterNodes) {
165  clusterNodes.clear();
166  getClusterInducedNodes(clusterNodes);
167  }
168 
170 
175  int getClusterNodes(NodeArray<bool>& clusterNode) {
176  int num = 0;
177  getClusterInducedNodes(clusterNode, num);
178  return num;
179  }
180 
182 
187  bool isDescendant(ClusterElement* child, bool allow_equal = false) {
188  OGDF_ASSERT(child != nullptr);
189  if (!allow_equal) {
190  child = child->parent();
191  }
192  while (child != this) {
193  if (child == nullptr) {
194  return false;
195  }
196  child = child->parent();
197  }
198  return true;
199  }
200 
202 
206 
209  ListConstIterator<ClusterElement*> cBegin() const { return children.begin(); }
210 
212  ListConstIterator<ClusterElement*> crBegin() const { return children.rbegin(); }
213 
215  int cCount() { return children.size(); }
216 
218  ListConstIterator<node> nBegin() const { return nodes.begin(); }
219 
221  int nCount() { return nodes.size(); }
222 
224  ListConstIterator<adjEntry> firstAdj() const { return adjEntries.begin(); }
225 
227  ListConstIterator<adjEntry> lastAdj() const { return adjEntries.rbegin(); }
228 
230 
232  static int compare(const ClusterElement& x, const ClusterElement& y) { return x.m_id - y.m_id; }
234 
236 };
237 
240 
243 #define forall_cluster_adj(adj, c) \
244  for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->firstAdj(); \
245  ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var, (adj)); \
246  ogdf_loop_var = ogdf_loop_var.succ())
247 
250 #define forall_cluster_rev_adj(adj, c) \
251  for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->lastAdj(); \
252  ogdf::test_forall_adj_entries_of_cluster(ogdf_loop_var, (adj)); \
253  ogdf_loop_var = ogdf_loop_var.pred())
254 
257 #define forall_cluster_adj_edges(e, c) \
258  for (ogdf::ListConstIterator<adjEntry> ogdf_loop_var = (c)->firstAdj(); \
259  ogdf::test_forall_adj_edges_of_cluster(ogdf_loop_var, (e)); \
260  ogdf_loop_var = ogdf_loop_var.succ())
261 
263  if (it.valid()) {
264  adj = (*it);
265  return true;
266  } else {
267  return false;
268  }
269 }
270 
272  adjEntry adj = (*it);
273  if (adj) {
274  e = adj->theEdge();
275  return true;
276  } else {
277  return false;
278  }
279 }
280 
282  if (adj) {
283  e = adj->theEdge();
284  return true;
285  } else {
286  return false;
287  }
288 }
289 
292 #define forall_clusters(c, C) for ((c) = (C).firstCluster(); (c); (c) = (c)->succ())
293 
296 #define forall_postOrderClusters(c, C) \
297  for ((c) = (C).firstPostOrderCluster(); (c); (c) = (c)->pSucc())
298 
300 
302 
303 template<typename Value, bool WithDefault>
305 
306 #define OGDF_DECL_REG_ARRAY_TYPE(v, c) ClusterArrayBase<v, c>
308 #undef OGDF_DECL_REG_ARRAY_TYPE
309 
319 class OGDF_EXPORT ClusterGraphObserver : public Observer<ClusterGraph, ClusterGraphObserver> {
320 public:
321  ClusterGraphObserver() = default;
322 
323  explicit ClusterGraphObserver(const ClusterGraph* CG) { reregister(CG); }
324 
325  virtual void clusterDeleted(cluster v) = 0;
326  virtual void clusterAdded(cluster v) = 0;
327  virtual void clustersCleared() = 0;
328 
329  const ClusterGraph* getGraph() const { return getObserved(); }
330 };
331 
333 
340  : public GraphObserver, // to get updates when graph nodes/edges added/removed
341  public Observable<ClusterGraphObserver, ClusterGraph>, // to publish updates when clusters added/removed
342  public ClusterGraphRegistry // for ClusterArrays
343 {
344  int m_clusterIdCount = 0;
345 
346  mutable cluster m_postOrderStart = nullptr;
347  cluster m_rootCluster = nullptr;
348 
349  bool m_adjAvailable = false;
350  bool m_allowEmptyClusters =
351  true;
352 
356 
357 public:
363 
367 
369 
374 
378 
380 
381 
383 
386  ClusterGraph();
387 
389 
392  explicit ClusterGraph(const Graph& G);
393 
395 
399  ClusterGraph(const ClusterGraph& C);
400 
402 
405  ClusterGraph(const ClusterGraph& C, Graph& G);
406 
408 
412  ClusterGraph(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
413  NodeArray<node>& originalNodeTable);
414 
416 
421  ClusterGraph(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
422  NodeArray<node>& originalNodeTable, EdgeArray<edge>& edgeCopy);
423 
425  virtual ~ClusterGraph();
426 
430 
433  cluster rootCluster() const { return m_rootCluster; }
434 
436  int numberOfClusters() const { return clusters.size(); }
437 
439  int maxClusterIndex() const { return m_clusterIdCount - 1; }
440 
442  inline cluster clusterOf(node v) const { return m_nodeMap[v]; }
443 
445  //should be called instead of direct c->depth call to assure
446  //valid depth
447  int& clusterDepth(cluster c) const {
448  // updateDepth must be set to true if depth info shall be used
449  OGDF_ASSERT(m_updateDepth);
450 
451  //initialize depth at first call
452  if (!m_depthUpToDate) {
453  computeSubTreeDepth(rootCluster());
454  }
455  OGDF_ASSERT(c->depth() != 0);
456  return c->m_depth;
457  }
458 
460  cluster firstCluster() const { return clusters.head(); }
461 
463  cluster lastCluster() const { return clusters.tail(); }
464 
467  if (!m_postOrderStart) {
468  postOrder();
469  }
470  return m_postOrderStart;
471  }
472 
474  template<class CLUSTERLIST>
475  void allClusters(CLUSTERLIST& clusterList) const {
476  clusterList.clear();
477  for (cluster c : clusters) {
478  clusterList.pushBack(c);
479  }
480  }
481 
483 
486 
489  void clear();
490 
492  void init(const Graph& G);
493 
495  void clearClusterTree(cluster C);
496 
498  cluster newCluster(cluster parent, int id = -1);
499 
501  cluster createEmptyCluster(const cluster parent = nullptr, int clusterId = -1);
502 
504 
512  cluster createCluster(const SList<node>& nodes, const cluster parent = nullptr);
513 
515 
519  void delCluster(cluster c);
520 
522  void moveCluster(cluster c, cluster newParent);
523 
524 
526  void reassignNode(node v, cluster c);
527 
529  //inserted mainly for use in gmlparser.
530  void reInit(Graph& G) { reinitGraph(G); }
531 
533  void copyClusterTree(
534  const ClusterGraph& C, const Graph& G, ClusterArray<cluster>& originalClusterTable,
535  std::function<node(node)> nodeMap = [](node v) { return v; });
536 
538  template<class NODELIST>
539  void collapse(NODELIST& nodes, Graph& G) {
540  OGDF_ASSERT(&G == &constGraph());
541  m_adjAvailable = false;
542 
543  m_postOrderStart = nullptr;
544  node v = nodes.popFrontRet();
545  while (!nodes.empty()) {
546  node w = nodes.popFrontRet();
547  adjEntry adj = w->firstAdj();
548  while (adj != nullptr) {
549  adjEntry succ = adj->succ();
550  edge e = adj->theEdge();
551  if (e->source() == v || e->target() == v) {
552  G.delEdge(e);
553  } else if (e->source() == w) {
554  G.moveSource(e, v);
555  } else {
556  G.moveTarget(e, v);
557  }
558  adj = succ;
559  }
560  //because nodes can already be unassigned (they are always
561  //unassigned if deleted), we have to check this
562 #if 0
563  if (m_nodeMap[w])
564  {
565  cluster c = m_nodeMap[w];
566  c->m_entries.del(m_itMap[w]);
567  }
568  removeNodeAssignment(w);
569 #endif
570  G.delNode(w);
571  }
572  }
573 
575 
576 
580 
589  cluster chooseCluster(
590  std::function<bool(cluster)> includeCluster = [](cluster) { return true; },
591  bool isFastTest = true) const;
592 
594  void setUpdateDepth(bool b) const {
595  m_updateDepth = b;
596  //make sure that depth cant be used anymore
597  //(even if it may still be valid a little while)
598  if (!b) {
599  m_depthUpToDate = false;
600  }
601  }
602 
604  void pullUpSubTree(cluster c);
605 
607  //maybe later we should provide a permanent depth member update
608  int treeDepth() const;
609 
611  void computeSubTreeDepth(cluster c) const;
612 
614  cluster commonCluster(SList<node>& nodes);
615 
617 
621  cluster c1, c2;
622  return commonClusterLastAncestors(v, w, c1, c2);
623  }
624 
627  List<cluster> eL;
628  return commonClusterAncestorsPath(v, w, c1, c2, eL);
629  }
630 
632 
636  cluster c1, c2;
637  return commonClusterAncestorsPath(v, w, c1, c2, eL);
638  }
639 
641  cluster commonClusterAncestorsPath(node v, node w, cluster& c1, cluster& c2,
642  List<cluster>& eL) const;
643 
645 
652  void emptyClusters(SList<cluster>& emptyCluster, SList<cluster>* checkCluster = nullptr);
653 
655  inline bool emptyOnNodeDelete(cluster c) //virtual?
656  {
657 #if 0
658  if (!c) {
659  return false; //Allows easy use in loops
660  }
661 #endif
662  return c->nCount() == 1 && c->cCount() == 0;
663  }
664 
666  inline bool emptyOnClusterDelete(cluster c) //virtual?
667  {
668 #if 0
669  if (!c) {
670  return false; //Allows easy use in loops
671  }
672 #endif
673  return c->nCount() == 0 && c->cCount() == 1;
674  }
675 
677 
680 
683  template<class EDGELIST>
684  void adjEdges(cluster c, EDGELIST& edges) const {
685  edges.clear();
686 
687  if (m_adjAvailable) {
688  edge e;
690  edges.pushBack(e);
691  }
692  }
693  }
694 
696  template<class ADJLIST>
697  void adjEntries(cluster c, ADJLIST& entries) const {
698  entries.clear();
699  if (m_adjAvailable) {
700  for (adjEntry adj : c->adjEntries) {
701  entries.pushBack(adj);
702  }
703  }
704  }
705 
707  template<class LISTITERATOR>
708  void makeAdjEntries(cluster c, LISTITERATOR start) {
709  c->adjEntries.clear();
710  LISTITERATOR its;
711  for (its = start; its.valid(); its++) {
712  adjEntry adj = (*its);
713  c->adjEntries.pushBack(adj);
714  }
715  }
716 
718  bool adjAvailable() const { return m_adjAvailable; }
719 
721  void adjAvailable(bool val) { m_adjAvailable = val; }
722 
724 
727 
730 
735  bool representsCombEmbedding() const;
736 
738 
746  bool representsConnectedCombEmbedding() const;
747 
748 #ifdef OGDF_DEBUG
749  void consistencyCheck() const;
751 #endif
752 
754 
759 
761  static inline int keyToIndex(cluster key) { return key->index(); }
762 
763  bool isKeyAssociated(cluster key) const {
764  if (key == nullptr) {
765  return false;
766  }
767 #ifdef OGDF_DEBUG
768  if (key->graphOf() == this) {
769  OGDF_ASSERT(keyToIndex(key) < this->getArraySize());
770  return true;
771  } else {
772  return false;
773  }
774 #else
775  return true;
776 #endif
777  }
778 
779  int calculateArraySize(int add) const { return calculateTableSize(m_clusterIdCount + add); }
780 
781  int maxKeyIndex() const { return (m_clusterIdCount)-1; }
782 
783  cluster_iterator begin() const { return clusters.begin(); }
784 
785  cluster_iterator end() const { return clusters.end(); }
786 
788 
791 
794  operator const Graph&() const { return *getGraph(); }
795 
797  const Graph& constGraph() const { return *getGraph(); }
798 
800  ClusterGraph& operator=(const ClusterGraph& C);
801 
803 
804 protected:
805  mutable std::unique_ptr<ClusterArray<int>> m_lcaSearch;
806  mutable int m_lcaNumber = 0;
807  mutable std::unique_ptr<ClusterArray<cluster>> m_vAncestor;
808  mutable std::unique_ptr<ClusterArray<cluster>> m_wAncestor;
809 
810  mutable bool m_updateDepth = false;
811  mutable bool m_depthUpToDate = false;
812 
815  cluster doCreateCluster(const SList<node>& nodes, const cluster parent, int clusterId = -1);
816 
819  cluster doCreateCluster(const SList<node>& nodes, SList<cluster>& emptyCluster,
820  const cluster parent, int clusterId = -1);
821 
823  void doClear();
824 
826  void copyLCA(const ClusterGraph& C);
827  //int m_treeDepth; //should be implemented and updated in operations?
828 
830  //we assume that c is inserted via pushback in newparent->children
831  void updatePostOrder(cluster c, cluster oldParent, cluster newParent);
832 
834  cluster postOrderPredecessor(cluster c) const;
835 
837  cluster leftMostCluster(cluster c) const;
838 
841 
843  void nodeDeleted(node v) override;
844 
846  void nodeAdded(node v) override { assignNode(v, rootCluster()); }
847 
849  void edgeDeleted(edge /* e */) override { }
850 
852  void edgeAdded(edge /* e */) override { }
853 
855  void cleared() override {
856  //we don't want a complete clear, as the graph still exists
857  //and can be updated from input stream
858  clear();
859  }
860 
861  void registrationChanged(const Graph* newG) override;
862 
864 
865 private:
867  template<typename T>
868  inline void fillEmptyClusters(SList<cluster>& emptyCluster, const T& clusterList) const {
869  emptyCluster.clear();
870 
871  for (cluster cc : clusterList) {
872  if (cc->cCount() + cc->nCount() == 0 && cc != rootCluster()) { // we dont add rootcluster
873  emptyCluster.pushBack(cc);
874  }
875  }
876  }
877 
880  m_adjAvailable = false;
881  for (auto child : c->getChildren()) {
882  clearClusterTree(child, attached);
883  }
884  }
885 
887  void assignNode(node v, cluster C);
888 
890  void unassignNode(node v);
891 
895  if (m_nodeMap[v]) //iff == 0, itmap == 0 !!?
896  {
897  cluster c2 = m_nodeMap[v];
898  c2->nodes.del(m_itMap[v]);
899  m_nodeMap[v] = nullptr;
900  m_itMap[v] = ListIterator<node>();
901  }
902  }
903 
906  void shallowCopy(const ClusterGraph& C);
907 
910  void deepCopy(const ClusterGraph& C, Graph& G);
911 
914  void deepCopy(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
915  NodeArray<node>& originalNodeTable);
916 
920  void deepCopy(const ClusterGraph& C, Graph& G, ClusterArray<cluster>& originalClusterTable,
921  NodeArray<node>& originalNodeTable, EdgeArray<edge>& edgeCopy);
922 
923 
924  void clearClusterTree(cluster c, List<node>& attached);
925 
926  void initGraph(const Graph& G);
927 
929  void reinitGraph(const Graph& G);
930 
932  cluster newCluster(int id);
933 
935  cluster newCluster();
936 
938  void postOrder() const;
939 
940 #ifdef OGDF_DEBUG
941  void checkPostOrder() const;
943 #endif
944 
945  void postOrder(cluster c, SListPure<cluster>& S) const;
946 };
947 
949 template<class Value, bool WithDefault>
950 class ClusterArrayBase : public RegisteredArray<ClusterGraph, Value, WithDefault> {
952 
953 public:
954  using RA::RA;
955 
957  ClusterArrayBase() = default;
958 
960  ClusterArrayBase(const ClusterGraph& C, const Value& def, int size) : RA(C, def) {
961  RA::resize(size, true);
962  };
963 
965  ClusterGraph* graphOf() const { return RA::registeredAt(); }
966 };
967 
968 OGDF_EXPORT std::ostream& operator<<(std::ostream& os, cluster c);
969 
971 
983 OGDF_EXPORT void planarizeClusterBorderCrossings(const ClusterGraph& CG, Graph& G,
984  EdgeArray<List<std::pair<adjEntry, cluster>>>* subdivisions,
985  const std::function<edge(edge)>& translate);
986 
987 }
ogdf::RegistryBase
Abstract base class for registries.
Definition: RegisteredArray.h:95
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::ClusterGraph::nodeAdded
void nodeAdded(node v) override
Implementation of inherited method: Updates data if node added.
Definition: ClusterGraph.h:846
ogdf::RegisteredArray
Dynamic arrays indexed with arbitrary keys.
Definition: RegisteredArray.h:808
OGDF_DECL_REG_ARRAY
#define OGDF_DECL_REG_ARRAY(NAME)
Definition: RegisteredArray.h:960
ogdf::internal::GraphList< GraphObject >::size
int size() const
Returns the size of the list.
Definition: GraphList.h:84
ogdf::ClusterGraph::m_lcaSearch
std::unique_ptr< ClusterArray< int > > m_lcaSearch
Used to save last search run number for commoncluster.
Definition: ClusterGraph.h:805
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:960
ogdf::internal::GraphList< GraphObject >::tail
GraphObject * tail() const
Returns the last element in the list.
Definition: GraphList.h:322
ogdf::ClusterGraphObserver::getGraph
const ClusterGraph * getGraph() const
Definition: ClusterGraph.h:329
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::internal::GraphIteratorBase
Definition: graph_iterators.h:44
ogdf::ClusterGraph::lastCluster
cluster lastCluster() const
Returns the last cluster in the list of all cluster.
Definition: ClusterGraph.h:463
ogdf::ClusterGraph::makeAdjEntries
void makeAdjEntries(cluster c, LISTITERATOR start)
Computes the adjacency entry list for cluster c.
Definition: ClusterGraph.h:708
ogdf::test_forall_adj_edges_of_cluster
bool test_forall_adj_edges_of_cluster(ListConstIterator< adjEntry > &it, edge &e)
Definition: ClusterGraph.h:271
ogdf::RegisteredArray::RA
typename std::conditional< WithDefault, internal::RegisteredArrayWithDefault< Registry, Value >, internal::RegisteredArrayWithoutDefault< Registry, Value > >::type RA
Definition: RegisteredArray.h:813
ogdf::ClusterGraph::m_nodeMap
NodeArray< cluster > m_nodeMap
Defines if empty clusters are deleted immediately if generated by operations.
Definition: ClusterGraph.h:353
ogdf::internal::GraphElement
The base class for objects used by (hyper)graphs.
Definition: GraphList.h:55
ogdf::EdgeArray
internal::EdgeArrayBase2< Value, WithDefault > EdgeArray
RegisteredArray for labeling the edges in a Graph with an arbitrary Value.
Definition: Graph_d.h:738
OGDF_AUGMENT_COMPARER
#define OGDF_AUGMENT_COMPARER(type)
Add this macro to your class to turn it into a full comparer.
Definition: comparer.h:179
ogdf::ClusterGraph::constGraph
const Graph & constGraph() const
Returns a reference to the underlying graph.
Definition: ClusterGraph.h:797
ogdf::ClusterArrayBase
RegisteredArray for labeling the clusters of a ClusterGraph.
Definition: ClusterGraph.h:304
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:164
ogdf::ClusterGraph::firstCluster
cluster firstCluster() const
Returns the first cluster in the list of all clusters.
Definition: ClusterGraph.h:460
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:594
forall_cluster_adj_edges
#define forall_cluster_adj_edges(e, c)
Iterates over all outgoing edges.
Definition: ClusterGraph.h:257
ogdf::SList
Singly linked lists (maintaining the length of the list).
Definition: SList.h:833
ogdf::ClusterGraph::emptyOnNodeDelete
bool emptyOnNodeDelete(cluster c)
Returns true if cluster c has only one node and no children.
Definition: ClusterGraph.h:655
ogdf::ClusterElement::getNodes
List< node > & getNodes()
Provides access to the encapsulated list of nodes (for friends of ClusterElement).
Definition: ClusterGraph.h:100
ogdf::ClusterElement::cCount
int cCount()
Returns the number of child clusters.
Definition: ClusterGraph.h:215
ogdf::ListIteratorBase::valid
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:143
ogdf::ClusterGraph::maxClusterIndex
int maxClusterIndex() const
Returns the maximal used cluster index.
Definition: ClusterGraph.h:439
ogdf::ClusterGraph::edgeAdded
void edgeAdded(edge) override
Implementation of inherited method: Updates data if edge added.
Definition: ClusterGraph.h:852
ogdf::ClusterElement::pred
cluster pred() const
Returns the predecessor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:152
ogdf::internal::GraphObjectContainer
Public read-only interface for lists of graph objects.
Definition: GraphList.h:405
ogdf::ClusterGraph::removeNodeAssignment
void removeNodeAssignment(node v)
Remove the assignment entries for nodes. Checks if node v is currently not assigned.
Definition: ClusterGraph.h:894
ogdf::ClusterElement::m_id
int m_id
The index of this cluster.
Definition: ClusterGraph.h:59
ogdf::ClusterGraphObserver
Abstract base class for cluster graph observers.
Definition: ClusterGraph.h:319
ogdf::ClusterElement::compare
static int compare(const ClusterElement &x, const ClusterElement &y)
Standard Comparer (uses cluster indices).
Definition: ClusterGraph.h:232
ogdf::ClusterElement::pPred
cluster pPred() const
Returns the postorder predecessor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:158
OGDF_NEW_DELETE
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
Definition: memory.h:84
ogdf::ClusterGraph::m_wAncestor
std::unique_ptr< ClusterArray< cluster > > m_wAncestor
Used to save last search run number for commoncluster.
Definition: ClusterGraph.h:808
ogdf::ClusterGraph::cleared
void cleared() override
Clears cluster data without deleting root when underlying graphs' clear method is called.
Definition: ClusterGraph.h:855
ogdf::ClusterGraph::edgeDeleted
void edgeDeleted(edge) override
Implementation of inherited method: Updates data if edge deleted.
Definition: ClusterGraph.h:849
ogdf::cluster
ClusterElement * cluster
The type of clusters.
Definition: ClusterGraph.h:49
ogdf::ListContainer::rbegin
reverse_iterator rbegin() const
Returns a reverse iterator to the last element in the container.
Definition: List.h:1834
ogdf::AdjElement
Class for adjacency list elements.
Definition: Graph_d.h:135
ogdf::ClusterElement::children
ListContainer< cluster, ClusterElement > children
The container containing the child clusters (children in the cluster tree) of this cluster.
Definition: ClusterGraph.h:74
ogdf::ListContainer::size
int size() const
Returns the number of elements in the container.
Definition: List.h:1840
ogdf::edge
EdgeElement * edge
The type of edges.
Definition: Graph_d.h:67
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:55
ogdf::AdjElement::theEdge
edge theEdge() const
Returns the edge associated with this adjacency entry.
Definition: Graph_d.h:153
ogdf::ClusterElement::graphOf
const ClusterGraph * graphOf() const
Definition: ClusterGraph.h:135
ogdf::ClusterElement::m_parent
cluster m_parent
The parent of this cluster.
Definition: ClusterGraph.h:85
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:475
ogdf::ClusterGraph::clusters
internal::GraphObjectContainer< ClusterElement > clusters
The container containing all cluster objects.
Definition: ClusterGraph.h:377
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:187
ogdf::ClusterGraph::adjAvailable
bool adjAvailable() const
Gets the availability status of the adjacency entries.
Definition: ClusterGraph.h:718
ogdf::ClusterGraphObserver::ClusterGraphObserver
ClusterGraphObserver(const ClusterGraph *CG)
Definition: ClusterGraph.h:323
ogdf::ClusterGraph::clusterDepth
int & clusterDepth(cluster c) const
Returns depth of cluster c in cluster tree, starting with root depth 1.
Definition: ClusterGraph.h:447
ogdf::ClusterElement::nCount
int nCount()
Returns the number of child nodes.
Definition: ClusterGraph.h:221
SList.h
Declaration of singly linked lists and iterators.
ogdf::AdjElement::succ
adjEntry succ() const
Returns the successor in the adjacency list.
Definition: Graph_d.h:211
ogdf::ClusterGraph::reInit
void reInit(Graph &G)
Clear cluster info structure, reinitializes with underlying graph G.
Definition: ClusterGraph.h:530
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:684
ogdf::calculateTableSize
int calculateTableSize(int actualCount)
The default growth function for registered arrays.
Definition: RegisteredArray.h:58
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:116
ogdf::ClusterGraph::isKeyAssociated
bool isKeyAssociated(cluster key) const
Definition: ClusterGraph.h:763
ogdf::ClusterGraph::begin
cluster_iterator begin() const
Definition: ClusterGraph.h:783
ogdf::ListContainer::begin
iterator begin() const
Returns an iterator to the first element in the container.
Definition: List.h:1828
ogdf::SListPure
Singly linked lists.
Definition: SList.h:39
ogdf::ClusterElement::succ
cluster succ() const
Returns the successor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:149
ogdf::operator<<
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.
Definition: Array.h:978
ogdf::ClusterGraph::end
cluster_iterator end() const
Definition: ClusterGraph.h:785
ogdf::EdgeElement::source
node source() const
Returns the source node of the edge.
Definition: Graph_d.h:391
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63
ogdf::GraphObserver
Abstract Base class for graph observers.
Definition: Graph_d.h:770
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:42
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::ClusterGraph::emptyOnClusterDelete
bool emptyOnClusterDelete(cluster c)
Returns true if cluster c has only one child and no nodes.
Definition: ClusterGraph.h:666
ogdf::internal::GraphList
Lists of graph objects (like nodes, edges, etc.).
Definition: GraphList.h:296
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:86
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:626
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:175
ogdf::ClusterElement::m_depth
int m_depth
The depth of this cluster in the cluster tree.
Definition: ClusterGraph.h:60
ogdf::test_forall_adj_entries_of_cluster
bool test_forall_adj_entries_of_cluster(ListConstIterator< adjEntry > &it, adjEntry &adj)
Definition: ClusterGraph.h:262
ogdf::SList::clear
void clear()
Removes all elements from the list.
Definition: SList.h:972
ogdf::ClusterElement::adjEntries
ListContainer< adjEntry, ClusterElement > adjEntries
The container containing the sorted list of adjacency entries of edges leaving this cluster.
Definition: ClusterGraph.h:80
GraphObserver.h
Abstract base class for structures on graphs, that need to be informed about graph changes (e....
ogdf::ListContainer
Definition: List.h:1818
ogdf::ClusterElement::depth
int depth() const
Returns the depth of the cluster in the cluster tree.
Definition: ClusterGraph.h:143
ogdf::ClusterElement::lastAdj
ListConstIterator< adjEntry > lastAdj() const
Returns the last adjacency entry in the list of outgoing edges.
Definition: ClusterGraph.h:227
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:697
ogdf::ClusterGraph::calculateArraySize
int calculateArraySize(int add) const
Definition: ClusterGraph.h:779
ogdf::ClusterGraph::numberOfClusters
int numberOfClusters() const
Returns the number of clusters.
Definition: ClusterGraph.h:436
ogdf::ClusterGraph::rootCluster
cluster rootCluster() const
Returns the root cluster.
Definition: ClusterGraph.h:433
ogdf::internal::GraphList< GraphObject >::begin
iterator begin() const
Returns an iterator to the first element in the container.
Definition: GraphList.h:380
ogdf::ClusterGraph::adjAvailable
void adjAvailable(bool val)
Sets the availability status of the adjacency entries.
Definition: ClusterGraph.h:721
ogdf::graphics::init
void init()
Definition: graphics.h:446
ogdf::internal::GraphList< GraphObject >::head
GraphObject * head() const
Returns the first element in the list.
Definition: GraphList.h:319
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:781
ogdf::ClusterElement::m_it
ListIterator< cluster > m_it
The position of this cluster within the children list of its parent.
Definition: ClusterGraph.h:88
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:539
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:620
ogdf::internal::GraphList< GraphObject >::end
iterator end() const
Returns an iterator to the one-past-last element in the container.
Definition: GraphList.h:383
ogdf::NodeElement::firstAdj
adjEntry firstAdj() const
Returns the first entry in the adjaceny list.
Definition: Graph_d.h:279
ogdf::ClusterElement::pSucc
cluster pSucc() const
Returns the postorder successor of the cluster in the list of all clusters.
Definition: ClusterGraph.h:155
ogdf::ClusterElement::nBegin
ListConstIterator< node > nBegin() const
Returns the first element in list of child nodes.
Definition: ClusterGraph.h:218
ogdf::ClusterElement::getChildren
List< cluster > & getChildren()
Provides access to the encapsulated list of children (for friends of ClusterElement).
Definition: ClusterGraph.h:97
ogdf::ClusterElement::m_pClusterGraph
const ClusterGraph * m_pClusterGraph
Definition: ClusterGraph.h:92
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
ogdf::ClusterElement::index
int index() const
Returns the (unique) index of the cluster.
Definition: ClusterGraph.h:140
ogdf::ClusterGraph::recurseClearClusterTreeOnChildren
void recurseClearClusterTreeOnChildren(cluster c, List< node > &attached)
Clears children of a cluster, used by recursive clearClusterTree.
Definition: ClusterGraph.h:879
ogdf::ClusterElement::parent
cluster parent()
Returns the parent of the cluster.
Definition: ClusterGraph.h:146
ogdf::ClusterGraph::clusterOf
cluster clusterOf(node v) const
Returns the cluster to which a node belongs.
Definition: ClusterGraph.h:442
ogdf::ClusterGraph::m_vAncestor
std::unique_ptr< ClusterArray< cluster > > m_vAncestor
Used to save last search run number for commoncluster.
Definition: ClusterGraph.h:807
ogdf::ClusterElement::m_pNext
cluster m_pNext
The postorder successor of this cluster.
Definition: ClusterGraph.h:87
ogdf::ClusterGraph::firstPostOrderCluster
cluster firstPostOrderCluster() const
Returns the first cluster in the list of post ordered clusters.
Definition: ClusterGraph.h:466
ogdf::ClusterElement::cBegin
ListConstIterator< ClusterElement * > cBegin() const
Returns the first element in the list of child clusters.
Definition: ClusterGraph.h:209
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:46
ogdf::ClusterElement::crBegin
ListConstIterator< ClusterElement * > crBegin() const
Returns the last element in the list of child clusters.
Definition: ClusterGraph.h:212
ogdf::ClusterElement::getAdjEntries
List< adjEntry > & getAdjEntries()
Provides access to the encapsulated list of adjacency entries (for friends of ClusterElement).
Definition: ClusterGraph.h:103
ogdf::ClusterArrayBase::graphOf
ClusterGraph * graphOf() const
Returns a pointer to the associated cluster graph.
Definition: ClusterGraph.h:965
ogdf::ClusterElement::nodes
ListContainer< node, ClusterElement > nodes
The container containing the nodes lying (directly) in this cluster.
Definition: ClusterGraph.h:71
ogdf::EdgeElement::target
node target() const
Returns the target node of the edge.
Definition: Graph_d.h:394
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:339
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::ClusterArrayBase::ClusterArrayBase
ClusterArrayBase()=default
Default Constructor.
ogdf::ClusterGraph::keyToIndex
static int keyToIndex(cluster key)
Definition: ClusterGraph.h:761
ogdf::SList::pushBack
SListIterator< E > pushBack(const E &x)
Adds element x at the end of the list.
Definition: SList.h:927
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::ClusterGraph::fillEmptyClusters
void fillEmptyClusters(SList< cluster > &emptyCluster, const T &clusterList) const
Fills emptyCluster with empty, non-root clusters from clusterList.
Definition: ClusterGraph.h:868
ogdf::List::clear
void clear()
Removes all elements from the list.
Definition: List.h:1616
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:635
ogdf::ClusterElement::firstAdj
ListConstIterator< adjEntry > firstAdj() const
Returns the first adjacency entry in the list of outgoing edges.
Definition: ClusterGraph.h:224