Open
Graph Drawing
Framework

 v. 2022.02 (Dogwood)
 

ClusterSet.h
Go to the documentation of this file.
1 
33 #pragma once
34 
36 #include <ogdf/basic/List.h>
37 
38 
39 
40 namespace ogdf {
41 
42 
44 
54 public:
56  explicit ClusterSetSimple(const ClusterGraph &C) : m_isContained(C, false) { }
57 
58  // destructor
60 
62 
67  void insert(cluster c) {
68  OGDF_ASSERT(c->graphOf() == m_isContained.graphOf());
69  bool &isContained = m_isContained[c];
70  if (!isContained) {
71  isContained = true;
72  m_clusters.pushFront(c);
73  }
74  }
75 
76 
78 
83  void clear() {
85  for(it = m_clusters.begin(); it.valid(); ++it) {
86  m_isContained[*it] = false;
87  }
88  m_clusters.clear();
89  }
90 
91 
93 
98  bool isMember(cluster c) const {
99  OGDF_ASSERT(c->graphOf() == m_isContained.graphOf());
100  return m_isContained[c];
101  }
102 
104 
107  const SListPure<cluster> &clusters() const {
108  return m_clusters;
109  }
110 
111 private:
114 
117 };
118 
119 
120 
122 
135 public:
137  explicit ClusterSetPure(const ClusterGraph &C) : m_it(C,ListIterator<cluster>()) { }
138 
139  // destructor
141 
143 
148  void insert(cluster c) {
149  OGDF_ASSERT(c->graphOf() == m_it.graphOf());
150  ListIterator<cluster> &itV = m_it[c];
151  if (!itV.valid())
152  itV = m_clusters.pushBack(c);
153  }
154 
156 
161  void remove(cluster c) {
162  OGDF_ASSERT(c->graphOf() == m_it.graphOf());
163  ListIterator<cluster> &itV = m_it[c];
164  if (itV.valid()) {
165  m_clusters.del(itV);
166  itV = ListIterator<cluster>();
167  }
168  }
169 
170 
172 
177  void clear() {
179  for(it = m_clusters.begin(); it.valid(); ++it) {
180  m_it[*it] = ListIterator<cluster>();
181  }
182  m_clusters.clear();
183  }
184 
185 
187 
192  bool isMember(cluster c) const {
193  OGDF_ASSERT(c->graphOf() == m_it.graphOf());
194  return m_it[c].valid();
195  }
196 
198 
201  const ListPure<cluster> &clusters() const {
202  return m_clusters;
203  }
204 
205 private:
209 
212 };
213 
214 
215 
217 
230 public:
232  explicit ClusterSet(const ClusterGraph &C) : m_it(C, ListIterator<cluster>()) { }
233 
234  // destructor
236 
238 
243  void insert(cluster c) {
244  OGDF_ASSERT(c->graphOf() == m_it.graphOf());
245  ListIterator<cluster> &itV = m_it[c];
246  if (!itV.valid())
247  itV = m_clusters.pushBack(c);
248  }
249 
251 
256  void remove(cluster c) {
257  OGDF_ASSERT(c->graphOf() == m_it.graphOf());
258  ListIterator<cluster> &itV = m_it[c];
259  if (itV.valid()) {
260  m_clusters.del(itV);
261  itV = ListIterator<cluster>();
262  }
263  }
264 
265 
267 
272  void clear() {
274  for(it = m_clusters.begin(); it.valid(); ++it) {
275  m_it[*it] = ListIterator<cluster>();
276  }
277  m_clusters.clear();
278  }
279 
280 
282 
287  bool isMember(cluster c) const {
288  OGDF_ASSERT(c->graphOf() == m_it.graphOf());
289  return m_it[c].valid();
290  }
291 
293 
296  int size() const {
297  return m_clusters.size();
298  }
299 
301 
304  const List<cluster> &clusters() const {
305  return m_clusters;
306  }
307 
308 private:
312 
315 };
316 
317 }
ogdf::ClusterSetPure
Cluster sets.
Definition: ClusterSet.h:134
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
ogdf::ClusterSetPure::m_it
ClusterArray< ListIterator< cluster > > m_it
m_it[c] contains the list iterator pointing to c if c is contained in S, an invalid list iterator oth...
Definition: ClusterSet.h:208
ogdf::ClusterSetSimple::ClusterSetSimple
ClusterSetSimple(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition: ClusterSet.h:56
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
ogdf::ClusterSet::clusters
const List< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition: ClusterSet.h:304
ogdf::ClusterSetSimple
Simple cluster sets.
Definition: ClusterSet.h:53
ogdf::ClusterSet::m_clusters
List< cluster > m_clusters
The list of clusters contained in S.
Definition: ClusterSet.h:314
ogdf::SListIteratorBase
Encapsulates a pointer to an ogdf::SList element.
Definition: SList.h:39
ogdf::ClusterSet::ClusterSet
ClusterSet(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition: ClusterSet.h:232
ogdf::ClusterSetSimple::clusters
const SListPure< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition: ClusterSet.h:107
ogdf::ListIteratorBase::valid
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:124
ogdf::ClusterSetSimple::insert
void insert(cluster c)
Inserts cluster c into S.
Definition: ClusterSet.h:67
ogdf::ClusterSetPure::isMember
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition: ClusterSet.h:192
ogdf::ClusterSet
Cluster sets.
Definition: ClusterSet.h:229
ogdf::ClusterSetPure::insert
void insert(cluster c)
Inserts cluster c into S.
Definition: ClusterSet.h:148
ogdf::SListIteratorBase::valid
bool valid() const
Returns true iff the iterator points to an element.
Definition: SList.h:115
ogdf::ClusterSetPure::m_clusters
ListPure< cluster > m_clusters
The list of clusters contained in S.
Definition: ClusterSet.h:211
ogdf::ClusterSet::size
int size() const
Returns the size of S.
Definition: ClusterSet.h:296
ogdf::ClusterSetPure::~ClusterSetPure
~ClusterSetPure()
Definition: ClusterSet.h:140
ogdf::ClusterElement
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
ogdf::ClusterSetSimple::~ClusterSetSimple
~ClusterSetSimple()
Definition: ClusterSet.h:59
ogdf::ClusterSet::isMember
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition: ClusterSet.h:287
ogdf::ClusterArray< bool >
ogdf::SListPure
Singly linked lists.
Definition: SList.h:38
ogdf::ClusterSetSimple::isMember
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition: ClusterSet.h:98
ClusterArray.h
Declaration and implementation of ClusterArray class.
ogdf::ClusterSet::m_it
ClusterArray< ListIterator< cluster > > m_it
m_it[c] contains the list iterator pointing to c if c is contained in S, an invalid list iterator oth...
Definition: ClusterSet.h:311
ogdf::List
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
ogdf::ClusterSetSimple::clear
void clear()
Removes all clusters from S.
Definition: ClusterSet.h:83
ogdf::ClusterSetSimple::m_isContained
ClusterArray< bool > m_isContained
m_isContained[c] is true iff c is contained in S
Definition: ClusterSet.h:113
ogdf::ClusterSetSimple::m_clusters
SListPure< cluster > m_clusters
The list of clusters contained in S.
Definition: ClusterSet.h:116
ogdf::ListPure
Doubly linked lists.
Definition: List.h:41
ogdf::ClusterSet::remove
void remove(cluster c)
Removes cluster c from S.
Definition: ClusterSet.h:256
ogdf::ClusterSetPure::clusters
const ListPure< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition: ClusterSet.h:201
ogdf::ClusterSetPure::remove
void remove(cluster c)
Removes cluster c from S.
Definition: ClusterSet.h:161
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
ogdf::ClusterSet::~ClusterSet
~ClusterSet()
Definition: ClusterSet.h:235
List.h
Declaration of doubly linked lists and iterators.
ogdf::ClusterSetPure::ClusterSetPure
ClusterSetPure(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition: ClusterSet.h:137
ogdf::ClusterSet::insert
void insert(cluster c)
Inserts cluster c into S.
Definition: ClusterSet.h:243
ogdf::ListIteratorBase
Encapsulates a pointer to a list element.
Definition: List.h:42
ogdf::ClusterSet::clear
void clear()
Removes all clusters from S.
Definition: ClusterSet.h:272
ogdf::ClusterSetPure::clear
void clear()
Removes all clusters from S.
Definition: ClusterSet.h:177
ogdf::ClusterGraph
Representation of clustered graphs.
Definition: ClusterGraph.h:291