Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

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 == false) {
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 
318 } // end namespace ogdf
void insert(cluster c)
Inserts cluster c into S.
Definition: ClusterSet.h:148
ListPure< cluster > m_clusters
The list of clusters contained in S.
Definition: ClusterSet.h:211
bool valid() const
Returns true iff the iterator points to an element.
Definition: SList.h:113
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
ClusterSet(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition: ClusterSet.h:232
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
SListPure< cluster > m_clusters
The list of clusters contained in S.
Definition: ClusterSet.h:116
Singly linked lists.
Definition: SList.h:38
void insert(cluster c)
Inserts cluster c into S.
Definition: ClusterSet.h:67
Doubly linked lists.
Definition: List.h:40
ClusterSetPure(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition: ClusterSet.h:137
Encapsulates a pointer to an ogdf::SList element.
Definition: SList.h:40
int size() const
Returns the size of S.
Definition: ClusterSet.h:296
Cluster sets.
Definition: ClusterSet.h:134
void clear()
Removes all clusters from S.
Definition: ClusterSet.h:83
const List< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition: ClusterSet.h:304
Simple cluster sets.
Definition: ClusterSet.h:53
void clear()
Removes all clusters from S.
Definition: ClusterSet.h:272
Representation of clustered graphs.
Definition: ClusterGraph.h:291
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition: ClusterSet.h:192
const SListPure< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition: ClusterSet.h:107
Doubly linked lists (maintaining the length of the list).
Definition: List.h:39
ClusterArray< bool > m_isContained
m_isContained[c] is true iff c is contained in S
Definition: ClusterSet.h:113
Encapsulates a pointer to a list element.
Definition: List.h:41
void insert(cluster c)
Inserts cluster c into S.
Definition: ClusterSet.h:243
List< cluster > m_clusters
The list of clusters contained in S.
Definition: ClusterSet.h:314
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition: ClusterSet.h:287
const ListPure< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition: ClusterSet.h:201
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
ClusterSetSimple(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition: ClusterSet.h:56
Declaration and implementation of ClusterArray class.
The namespace for all OGDF objects.
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
Cluster sets.
Definition: ClusterSet.h:229
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition: ClusterSet.h:98
void clear()
Removes all clusters from S.
Definition: ClusterSet.h:177
bool valid() const
Returns true iff the iterator points to an element.
Definition: List.h:112
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
Declaration of doubly linked lists and iterators.