Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
HypergraphArray.h
Go to the documentation of this file.
1
34#pragma once
35
37
38namespace ogdf {
39
42public:
48
51
54
57
60
62 const Hypergraph* hypergraphOf() const { return m_hypergraph; }
63
65 virtual void reinit(int initTableSize) = 0;
66
68 virtual void reregister(const Hypergraph* H) = 0;
69
71 virtual void enlargeTable(int newTableSize) = 0;
72
74 virtual void disconnect() = 0;
75};
76
78
81template<class T>
82class HypernodeArray : private Array<T>, protected HypergraphArrayBase {
84 T m_x;
85
86public:
89
91 HypernodeArray(const Hypergraph& H, const T& x)
92 : Array<T>(0, H.hypernodeArrayTableSize() - 1, x), HypergraphArrayBase(&H), m_x(x) {
93 m_it = H.registerHypernodeArray(this);
94 }
95
101
104
106 const T& operator[](int index) const { return Array<T>::operator[](index); }
107
109 T& operator[](int index) { return Array<T>::operator[](index); }
110
114 m_x = a.m_x;
116 return *this;
117 }
118
120 void init(const Hypergraph& H) {
121 Array<T>::init(H.hypernodeArrayTableSize());
122 reregister(&H);
123 }
124
126 void init(const Hypergraph& H, const T& x) {
127 Array<T>::init(0, H.hypernodeArrayTableSize() - 1, m_x = 0);
128 reregister(&H);
129 }
130
131 virtual void reregister(const Hypergraph* H) {
132 if (m_hypergraph) {
134 }
135
136 if ((m_hypergraph = H) != nullptr) {
137 m_it = H->registerHypernodeArray(this);
138 }
139 }
140
141private:
143
144 virtual void reinit(int initTableSize) { Array<T>::init(0, initTableSize - 1, m_x); }
145
146 virtual void disconnect() {
148 m_hypergraph = nullptr;
149 }
150
152};
153
155
158template<class T>
159class HyperedgeArray : private Array<T>, protected HypergraphArrayBase {
162
163public:
166
168 HyperedgeArray(const Hypergraph& H, const T& x)
169 : Array<T>(0, H.hyperedgeArrayTableSize() - 1, x), HypergraphArrayBase(&H), m_x(x) {
170 m_it = H.registerHyperedgeArray(this);
171 }
172
174 virtual ~HyperedgeArray() {
175 if (m_hypergraph) {
177 }
178 }
179
181 bool valid() const { return Array<T>::low() <= Array<T>::high(); }
182
185
187 const T& operator[](int index) const { return Array<T>::operator[](index); }
188
190 T& operator[](int index) { return Array<T>::operator[](index); }
191
195 m_x = a.m_x;
197 return *this;
198 }
199
201 void init(const Hypergraph& H) {
202 Array<T>::init(H.hyperedgeArrayTableSize());
203 reregister(&H);
204 }
205
207 void init(const Hypergraph& H, const T& x) {
208 Array<T>::init(0, H.hyperedgeArrayTableSize() - 1, m_x = 0);
209 reregister(&H);
210 }
211
212 virtual void reregister(const Hypergraph* H) {
213 if (m_hypergraph) {
215 }
216
217 if ((m_hypergraph = H) != nullptr) {
218 m_it = H->registerHyperedgeArray(this);
219 }
220 }
221
222private:
224
225 virtual void reinit(int initTableSize) { Array<T>::init(0, initTableSize - 1, m_x); }
226
227 virtual void disconnect() {
229 m_hypergraph = nullptr;
230 }
231
233};
234
235}
Declaration and a partial implementation of a Hypergraph class partly based on the original classes f...
The parameterized class Array implements dynamic arrays of type E.
Definition Array.h:214
const_reference operator[](INDEX i) const
Returns a reference to the element at position i.
Definition Array.h:303
void resize(INDEX newSize, const E &x)
Resizes (enlarges or shrinks) the array to hold newSize elements and sets new elements to x.
Definition Array.h:437
INDEX high() const
Returns the maximal array index.
Definition Array.h:294
void init()
Reinitializes the array to an array with empty index set.
Definition Array.h:367
Array< E, INDEX > & operator=(const Array< E, INDEX > &A)
Assignment operator.
Definition Array.h:447
INDEX low() const
Returns the minimal array index.
Definition Array.h:291
Dynamic arrays indexed with nodes.
virtual void enlargeTable(int newTableSize)
Table size enlargement.
bool valid() const
Returns true iff the array is associated with a hypergraph.
void init(const Hypergraph &H, const T &x)
Reinitializes the array. Associates the array with H.
HyperedgeArray()
Constructs an empty hypernode array associated with no graph.
HyperedgeArray(const Hypergraph &H, const T &x)
Constructs a hypernode array associated with H.
HyperedgeArray< T > & operator=(const HyperedgeArray< T > &a)
Assignment operator.
void init(const Hypergraph &H)
Reinitializes the array. Associates the array with H.
virtual void reregister(const Hypergraph *H)
Associates the array with a new hypergraph.
virtual void reinit(int initTableSize)
Table re-initialization.
T m_x
The default value for array elements.
T & operator[](int index)
Returns a reference to the element with index index.
T & operator[](hyperedge e)
Returns a reference to the element with the index of e.
virtual void disconnect()
Disconnetion from the hypergraph.
const T & operator[](int index) const
Returns a reference to the element with index index.
virtual ~HyperedgeArray()
Destructor.
Class for the representation of hyperedges.
Definition Hypergraph.h:135
int index() const
Returns the index of a hyperedge.
Definition Hypergraph.h:162
Abstract base class for hypergraph arrays.
HypergraphArrayBase(const Hypergraph *pH)
Initializes an array associated with pH.
virtual void reinit(int initTableSize)=0
Table re-initialization.
const Hypergraph * hypergraphOf() const
Returns a pointer to the associated hypergraph.
HypergraphArrayBase()
Initializes an array not associated with a hypergraph.
virtual void reregister(const Hypergraph *H)=0
Associates the array with a new hypergraph.
const Hypergraph * m_hypergraph
The associated hypergraph.
virtual ~HypergraphArrayBase()
Destructor, unregisters the array.
virtual void enlargeTable(int newTableSize)=0
Table size enlargement.
virtual void disconnect()=0
Disconnetion from the hypergraph.
ListIterator< HypergraphArrayBase * > m_it
Pointer to list element in the list of all registered hypergraph arrays which references this array.
void unregisterHypernodeArray(ListIterator< HypergraphArrayBase * > it) const
Unregisters a hypernode array.
void unregisterHyperedgeArray(ListIterator< HypergraphArrayBase * > it) const
Unregisters an hyperedge array.
Dynamic arrays indexed with hypernodes.
T & operator[](hypernode v)
Returns a reference to the element with index v.
const T & operator[](int index) const
Returns a reference to the element with index index.
virtual void reinit(int initTableSize)
Table re-initialization.
virtual void disconnect()
Disconnetion from the hypergraph.
virtual void enlargeTable(int newTableSize)
Table size enlargement.
HypernodeArray(const Hypergraph &H, const T &x)
Constructs a hypernode array associated with H.
HypernodeArray()
Constructs an empty hypernode array associated with no hypergraph.
HypernodeArray< T > & operator=(const HypernodeArray< T > &a)
Assignment operator.
virtual void reregister(const Hypergraph *H)
Associates the array with a new hypergraph.
T m_x
The default value for array elements.
void init(const Hypergraph &H, const T &x)
Reinitializes the array. Associates the array with H.
T & operator[](int index)
Returns a reference to the element with index index.
void init(const Hypergraph &H)
Reinitializes the array. Associates the array with H.
Class for the representation of hypernodes.
Definition Hypergraph.h:215
int index() const
Returns the (unique) hypernode index.
Definition Hypergraph.h:263
Encapsulates a pointer to a list element.
Definition List.h:103
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.