Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ClusterSet.h
Go to the documentation of this file.
1
33#pragma once
34
35#include <ogdf/basic/List.h>
37
38namespace ogdf {
39
40
42
52public:
54 explicit ClusterSetSimple(const ClusterGraph& C) : m_isContained(C, false) { }
55
56 // destructor
58
60
65 void insert(cluster c) {
66 OGDF_ASSERT(c->graphOf() == m_isContained.graphOf());
67 bool& isContained = m_isContained[c];
68 if (!isContained) {
69 isContained = true;
70 m_clusters.pushFront(c);
71 }
72 }
73
75
80 void clear() {
82 for (it = m_clusters.begin(); it.valid(); ++it) {
83 m_isContained[*it] = false;
84 }
85 m_clusters.clear();
86 }
87
89
94 bool isMember(cluster c) const {
95 OGDF_ASSERT(c->graphOf() == m_isContained.graphOf());
96 return m_isContained[c];
97 }
98
100
103 const SListPure<cluster>& clusters() const { return m_clusters; }
104
105private:
108
111};
112
114
127public:
129 explicit ClusterSetPure(const ClusterGraph& C) : m_it(C, ListIterator<cluster>()) { }
130
131 // destructor
133
135
140 void insert(cluster c) {
141 OGDF_ASSERT(c->graphOf() == m_it.graphOf());
142 ListIterator<cluster>& itV = m_it[c];
143 if (!itV.valid()) {
144 itV = m_clusters.pushBack(c);
145 }
146 }
147
149
154 void remove(cluster c) {
155 OGDF_ASSERT(c->graphOf() == m_it.graphOf());
156 ListIterator<cluster>& itV = m_it[c];
157 if (itV.valid()) {
158 m_clusters.del(itV);
160 }
161 }
162
164
169 void clear() {
171 for (it = m_clusters.begin(); it.valid(); ++it) {
172 m_it[*it] = ListIterator<cluster>();
173 }
174 m_clusters.clear();
175 }
176
178
183 bool isMember(cluster c) const {
184 OGDF_ASSERT(c->graphOf() == m_it.graphOf());
185 return m_it[c].valid();
186 }
187
189
192 const ListPure<cluster>& clusters() const { return m_clusters; }
193
194private:
198
201};
202
204
217public:
219 explicit ClusterSet(const ClusterGraph& C) : m_it(C, ListIterator<cluster>()) { }
220
221 // destructor
223
225
230 void insert(cluster c) {
231 OGDF_ASSERT(c->graphOf() == m_it.graphOf());
232 ListIterator<cluster>& itV = m_it[c];
233 if (!itV.valid()) {
234 itV = m_clusters.pushBack(c);
235 }
236 }
237
239
244 void remove(cluster c) {
245 OGDF_ASSERT(c->graphOf() == m_it.graphOf());
246 ListIterator<cluster>& itV = m_it[c];
247 if (itV.valid()) {
248 m_clusters.del(itV);
250 }
251 }
252
254
259 void clear() {
261 for (it = m_clusters.begin(); it.valid(); ++it) {
262 m_it[*it] = ListIterator<cluster>();
263 }
264 m_clusters.clear();
265 }
266
268
273 bool isMember(cluster c) const {
274 OGDF_ASSERT(c->graphOf() == m_it.graphOf());
275 return m_it[c].valid();
276 }
277
279
282 int size() const { return m_clusters.size(); }
283
285
288 const List<cluster>& clusters() const { return m_clusters; }
289
290private:
294
297};
298
299}
Declaration and implementation of ClusterArray class.
Declaration of doubly linked lists and iterators.
Dynamic arrays indexed with clusters.
Representation of clusters in a clustered graph.
Representation of clustered graphs.
Cluster sets.
Definition ClusterSet.h:216
void clear()
Removes all clusters from S.
Definition ClusterSet.h:259
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition ClusterSet.h:273
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:293
void remove(cluster c)
Removes cluster c from S.
Definition ClusterSet.h:244
const List< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition ClusterSet.h:288
ClusterSet(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition ClusterSet.h:219
int size() const
Returns the size of S.
Definition ClusterSet.h:282
List< cluster > m_clusters
The list of clusters contained in S.
Definition ClusterSet.h:296
void insert(cluster c)
Inserts cluster c into S.
Definition ClusterSet.h:230
Cluster sets.
Definition ClusterSet.h:126
const ListPure< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition ClusterSet.h:192
void insert(cluster c)
Inserts cluster c into S.
Definition ClusterSet.h:140
void remove(cluster c)
Removes cluster c from S.
Definition ClusterSet.h:154
ListPure< cluster > m_clusters
The list of clusters contained in S.
Definition ClusterSet.h:200
ClusterSetPure(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition ClusterSet.h:129
void clear()
Removes all clusters from S.
Definition ClusterSet.h:169
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:197
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition ClusterSet.h:183
Simple cluster sets.
Definition ClusterSet.h:51
void insert(cluster c)
Inserts cluster c into S.
Definition ClusterSet.h:65
const SListPure< cluster > & clusters() const
Returns a reference to the list of clusters contained in S.
Definition ClusterSet.h:103
void clear()
Removes all clusters from S.
Definition ClusterSet.h:80
ClusterArray< bool > m_isContained
m_isContained[c] is true iff c is contained in S
Definition ClusterSet.h:107
SListPure< cluster > m_clusters
The list of clusters contained in S.
Definition ClusterSet.h:110
bool isMember(cluster c) const
Returns true if cluster c is contained in S, false otherwise.
Definition ClusterSet.h:94
ClusterSetSimple(const ClusterGraph &C)
Creates an empty cluster set associated with clustered graph C.
Definition ClusterSet.h:54
Doubly linked lists (maintaining the length of the list).
Definition List.h:1435
Encapsulates a pointer to a list element.
Definition List.h:103
bool valid() const
Returns true iff the iterator points to an element.
Definition List.h:137
Doubly linked lists.
Definition List.h:217
Encapsulates a pointer to an ogdf::SList element.
Definition SList.h:92
bool valid() const
Returns true iff the iterator points to an element.
Definition SList.h:122
Singly linked lists.
Definition SList.h:179
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:41
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.