0
2
0
... | ... |
@@ -235,96 +235,98 @@ |
235 | 235 |
ArcMap& operator=(const CMap& cmap) { |
236 | 236 |
Parent::operator=(cmap); |
237 | 237 |
return *this; |
238 | 238 |
} |
239 | 239 |
|
240 | 240 |
}; |
241 | 241 |
|
242 | 242 |
|
243 | 243 |
// Alteration extension |
244 | 244 |
|
245 | 245 |
Arc addArc(const Node& from, const Node& to) { |
246 | 246 |
Arc arc = Parent::addArc(from, to); |
247 | 247 |
notifier(Arc()).add(arc); |
248 | 248 |
return arc; |
249 | 249 |
} |
250 | 250 |
|
251 | 251 |
void clear() { |
252 | 252 |
notifier(Arc()).clear(); |
253 | 253 |
Parent::clear(); |
254 | 254 |
} |
255 | 255 |
|
256 | 256 |
void erase(const Arc& arc) { |
257 | 257 |
notifier(Arc()).erase(arc); |
258 | 258 |
Parent::erase(arc); |
259 | 259 |
} |
260 | 260 |
|
261 | 261 |
ArcSetExtender() { |
262 | 262 |
arc_notifier.setContainer(*this); |
263 | 263 |
} |
264 | 264 |
|
265 | 265 |
~ArcSetExtender() { |
266 | 266 |
arc_notifier.clear(); |
267 | 267 |
} |
268 | 268 |
|
269 | 269 |
}; |
270 | 270 |
|
271 | 271 |
|
272 | 272 |
// \ingroup digraphbits |
273 | 273 |
// |
274 | 274 |
// \brief Extender for the EdgeSets |
275 | 275 |
template <typename Base> |
276 | 276 |
class EdgeSetExtender : public Base { |
277 | 277 |
typedef Base Parent; |
278 | 278 |
|
279 | 279 |
public: |
280 | 280 |
|
281 | 281 |
typedef EdgeSetExtender Graph; |
282 | 282 |
|
283 |
typedef True UndirectedTag; |
|
284 |
|
|
283 | 285 |
typedef typename Parent::Node Node; |
284 | 286 |
typedef typename Parent::Arc Arc; |
285 | 287 |
typedef typename Parent::Edge Edge; |
286 | 288 |
|
287 | 289 |
int maxId(Node) const { |
288 | 290 |
return Parent::maxNodeId(); |
289 | 291 |
} |
290 | 292 |
|
291 | 293 |
int maxId(Arc) const { |
292 | 294 |
return Parent::maxArcId(); |
293 | 295 |
} |
294 | 296 |
|
295 | 297 |
int maxId(Edge) const { |
296 | 298 |
return Parent::maxEdgeId(); |
297 | 299 |
} |
298 | 300 |
|
299 | 301 |
Node fromId(int id, Node) const { |
300 | 302 |
return Parent::nodeFromId(id); |
301 | 303 |
} |
302 | 304 |
|
303 | 305 |
Arc fromId(int id, Arc) const { |
304 | 306 |
return Parent::arcFromId(id); |
305 | 307 |
} |
306 | 308 |
|
307 | 309 |
Edge fromId(int id, Edge) const { |
308 | 310 |
return Parent::edgeFromId(id); |
309 | 311 |
} |
310 | 312 |
|
311 | 313 |
Node oppositeNode(const Node &n, const Edge &e) const { |
312 | 314 |
if( n == Parent::u(e)) |
313 | 315 |
return Parent::v(e); |
314 | 316 |
else if( n == Parent::v(e)) |
315 | 317 |
return Parent::u(e); |
316 | 318 |
else |
317 | 319 |
return INVALID; |
318 | 320 |
} |
319 | 321 |
|
320 | 322 |
Arc oppositeArc(const Arc &e) const { |
321 | 323 |
return Parent::direct(e, !Parent::direction(e)); |
322 | 324 |
} |
323 | 325 |
|
324 | 326 |
using Parent::direct; |
325 | 327 |
Arc direct(const Edge &e, const Node &s) const { |
326 | 328 |
return Parent::direct(e, Parent::u(e) == s); |
327 | 329 |
} |
328 | 330 |
|
329 | 331 |
typedef AlterationNotifier<EdgeSetExtender, Arc> ArcNotifier; |
330 | 332 |
typedef AlterationNotifier<EdgeSetExtender, Edge> EdgeNotifier; |
... | ... |
@@ -136,96 +136,98 @@ |
136 | 136 |
class InArcIt : public Arc { |
137 | 137 |
const Adaptor* _adaptor; |
138 | 138 |
public: |
139 | 139 |
|
140 | 140 |
InArcIt() { } |
141 | 141 |
|
142 | 142 |
InArcIt(Invalid i) : Arc(i) { } |
143 | 143 |
|
144 | 144 |
InArcIt(const Adaptor& adaptor, const Node& node) |
145 | 145 |
: _adaptor(&adaptor) { |
146 | 146 |
_adaptor->firstIn(*this, node); |
147 | 147 |
} |
148 | 148 |
|
149 | 149 |
InArcIt(const Adaptor& adaptor, const Arc& arc) : |
150 | 150 |
Arc(arc), _adaptor(&adaptor) {} |
151 | 151 |
|
152 | 152 |
InArcIt& operator++() { |
153 | 153 |
_adaptor->nextIn(*this); |
154 | 154 |
return *this; |
155 | 155 |
} |
156 | 156 |
|
157 | 157 |
}; |
158 | 158 |
|
159 | 159 |
Node baseNode(const OutArcIt &e) const { |
160 | 160 |
return Parent::source(e); |
161 | 161 |
} |
162 | 162 |
Node runningNode(const OutArcIt &e) const { |
163 | 163 |
return Parent::target(e); |
164 | 164 |
} |
165 | 165 |
|
166 | 166 |
Node baseNode(const InArcIt &e) const { |
167 | 167 |
return Parent::target(e); |
168 | 168 |
} |
169 | 169 |
Node runningNode(const InArcIt &e) const { |
170 | 170 |
return Parent::source(e); |
171 | 171 |
} |
172 | 172 |
|
173 | 173 |
}; |
174 | 174 |
|
175 | 175 |
template <typename _Graph> |
176 | 176 |
class GraphAdaptorExtender : public _Graph { |
177 | 177 |
typedef _Graph Parent; |
178 | 178 |
|
179 | 179 |
public: |
180 | 180 |
|
181 | 181 |
typedef _Graph Graph; |
182 | 182 |
typedef GraphAdaptorExtender Adaptor; |
183 | 183 |
|
184 |
typedef True UndirectedTag; |
|
185 |
|
|
184 | 186 |
typedef typename Parent::Node Node; |
185 | 187 |
typedef typename Parent::Arc Arc; |
186 | 188 |
typedef typename Parent::Edge Edge; |
187 | 189 |
|
188 | 190 |
// Graph extension |
189 | 191 |
|
190 | 192 |
int maxId(Node) const { |
191 | 193 |
return Parent::maxNodeId(); |
192 | 194 |
} |
193 | 195 |
|
194 | 196 |
int maxId(Arc) const { |
195 | 197 |
return Parent::maxArcId(); |
196 | 198 |
} |
197 | 199 |
|
198 | 200 |
int maxId(Edge) const { |
199 | 201 |
return Parent::maxEdgeId(); |
200 | 202 |
} |
201 | 203 |
|
202 | 204 |
Node fromId(int id, Node) const { |
203 | 205 |
return Parent::nodeFromId(id); |
204 | 206 |
} |
205 | 207 |
|
206 | 208 |
Arc fromId(int id, Arc) const { |
207 | 209 |
return Parent::arcFromId(id); |
208 | 210 |
} |
209 | 211 |
|
210 | 212 |
Edge fromId(int id, Edge) const { |
211 | 213 |
return Parent::edgeFromId(id); |
212 | 214 |
} |
213 | 215 |
|
214 | 216 |
Node oppositeNode(const Node &n, const Edge &e) const { |
215 | 217 |
if( n == Parent::u(e)) |
216 | 218 |
return Parent::v(e); |
217 | 219 |
else if( n == Parent::v(e)) |
218 | 220 |
return Parent::u(e); |
219 | 221 |
else |
220 | 222 |
return INVALID; |
221 | 223 |
} |
222 | 224 |
|
223 | 225 |
Arc oppositeArc(const Arc &a) const { |
224 | 226 |
return Parent::direct(a, !Parent::direction(a)); |
225 | 227 |
} |
226 | 228 |
|
227 | 229 |
using Parent::direct; |
228 | 230 |
Arc direct(const Edge &e, const Node &s) const { |
229 | 231 |
return Parent::direct(e, Parent::u(e) == s); |
230 | 232 |
} |
231 | 233 |
|
0 comments (0 inline)