... |
... |
@@ -70,155 +70,157 @@
|
70 |
70 |
///
|
71 |
71 |
/// Assignment operator for the item.
|
72 |
72 |
GraphItem& operator=(const GraphItem&) { return *this; }
|
73 |
73 |
|
74 |
74 |
/// \brief Assignment operator for INVALID.
|
75 |
75 |
///
|
76 |
76 |
/// This operator makes the item invalid.
|
77 |
77 |
GraphItem& operator=(Invalid) { return *this; }
|
78 |
78 |
|
79 |
79 |
/// \brief Equality operator.
|
80 |
80 |
///
|
81 |
81 |
/// Equality operator.
|
82 |
82 |
bool operator==(const GraphItem&) const { return false; }
|
83 |
83 |
|
84 |
84 |
/// \brief Inequality operator.
|
85 |
85 |
///
|
86 |
86 |
/// Inequality operator.
|
87 |
87 |
bool operator!=(const GraphItem&) const { return false; }
|
88 |
88 |
|
89 |
89 |
/// \brief Ordering operator.
|
90 |
90 |
///
|
91 |
91 |
/// This operator defines an ordering of the items.
|
92 |
92 |
/// It makes possible to use graph item types as key types in
|
93 |
93 |
/// associative containers (e.g. \c std::map).
|
94 |
94 |
///
|
95 |
95 |
/// \note This operator only has to define some strict ordering of
|
96 |
96 |
/// the items; this order has nothing to do with the iteration
|
97 |
97 |
/// ordering of the items.
|
98 |
98 |
bool operator<(const GraphItem&) const { return false; }
|
99 |
99 |
|
100 |
100 |
template<typename _GraphItem>
|
101 |
101 |
struct Constraints {
|
102 |
102 |
void constraints() {
|
103 |
103 |
_GraphItem i1;
|
104 |
104 |
i1=INVALID;
|
105 |
105 |
_GraphItem i2 = i1;
|
106 |
106 |
_GraphItem i3 = INVALID;
|
107 |
107 |
|
108 |
108 |
i1 = i2 = i3;
|
109 |
109 |
|
110 |
110 |
bool b;
|
111 |
111 |
b = (ia == ib) && (ia != ib);
|
112 |
112 |
b = (ia == INVALID) && (ib != INVALID);
|
113 |
113 |
b = (ia < ib);
|
114 |
114 |
}
|
115 |
115 |
|
116 |
116 |
const _GraphItem &ia;
|
117 |
117 |
const _GraphItem &ib;
|
|
118 |
Constraints() {}
|
118 |
119 |
};
|
119 |
120 |
};
|
120 |
121 |
|
121 |
122 |
/// \brief Base skeleton class for directed graphs.
|
122 |
123 |
///
|
123 |
124 |
/// This class describes the base interface of directed graph types.
|
124 |
125 |
/// All digraph %concepts have to conform to this class.
|
125 |
126 |
/// It just provides types for nodes and arcs and functions
|
126 |
127 |
/// to get the source and the target nodes of arcs.
|
127 |
128 |
class BaseDigraphComponent {
|
128 |
129 |
public:
|
129 |
130 |
|
130 |
131 |
typedef BaseDigraphComponent Digraph;
|
131 |
132 |
|
132 |
133 |
/// \brief Node class of the digraph.
|
133 |
134 |
///
|
134 |
135 |
/// This class represents the nodes of the digraph.
|
135 |
136 |
typedef GraphItem<'n'> Node;
|
136 |
137 |
|
137 |
138 |
/// \brief Arc class of the digraph.
|
138 |
139 |
///
|
139 |
140 |
/// This class represents the arcs of the digraph.
|
140 |
141 |
typedef GraphItem<'a'> Arc;
|
141 |
142 |
|
142 |
143 |
/// \brief Return the source node of an arc.
|
143 |
144 |
///
|
144 |
145 |
/// This function returns the source node of an arc.
|
145 |
146 |
Node source(const Arc&) const { return INVALID; }
|
146 |
147 |
|
147 |
148 |
/// \brief Return the target node of an arc.
|
148 |
149 |
///
|
149 |
150 |
/// This function returns the target node of an arc.
|
150 |
151 |
Node target(const Arc&) const { return INVALID; }
|
151 |
152 |
|
152 |
153 |
/// \brief Return the opposite node on the given arc.
|
153 |
154 |
///
|
154 |
155 |
/// This function returns the opposite node on the given arc.
|
155 |
156 |
Node oppositeNode(const Node&, const Arc&) const {
|
156 |
157 |
return INVALID;
|
157 |
158 |
}
|
158 |
159 |
|
159 |
160 |
template <typename _Digraph>
|
160 |
161 |
struct Constraints {
|
161 |
162 |
typedef typename _Digraph::Node Node;
|
162 |
163 |
typedef typename _Digraph::Arc Arc;
|
163 |
164 |
|
164 |
165 |
void constraints() {
|
165 |
166 |
checkConcept<GraphItem<'n'>, Node>();
|
166 |
167 |
checkConcept<GraphItem<'a'>, Arc>();
|
167 |
168 |
{
|
168 |
169 |
Node n;
|
169 |
170 |
Arc e(INVALID);
|
170 |
171 |
n = digraph.source(e);
|
171 |
172 |
n = digraph.target(e);
|
172 |
173 |
n = digraph.oppositeNode(n, e);
|
173 |
174 |
}
|
174 |
175 |
}
|
175 |
176 |
|
176 |
177 |
const _Digraph& digraph;
|
|
178 |
Constraints() {}
|
177 |
179 |
};
|
178 |
180 |
};
|
179 |
181 |
|
180 |
182 |
/// \brief Base skeleton class for undirected graphs.
|
181 |
183 |
///
|
182 |
184 |
/// This class describes the base interface of undirected graph types.
|
183 |
185 |
/// All graph %concepts have to conform to this class.
|
184 |
186 |
/// It extends the interface of \ref BaseDigraphComponent with an
|
185 |
187 |
/// \c Edge type and functions to get the end nodes of edges,
|
186 |
188 |
/// to convert from arcs to edges and to get both direction of edges.
|
187 |
189 |
class BaseGraphComponent : public BaseDigraphComponent {
|
188 |
190 |
public:
|
189 |
191 |
|
190 |
192 |
typedef BaseGraphComponent Graph;
|
191 |
193 |
|
192 |
194 |
typedef BaseDigraphComponent::Node Node;
|
193 |
195 |
typedef BaseDigraphComponent::Arc Arc;
|
194 |
196 |
|
195 |
197 |
/// \brief Undirected edge class of the graph.
|
196 |
198 |
///
|
197 |
199 |
/// This class represents the undirected edges of the graph.
|
198 |
200 |
/// Undirected graphs can be used as directed graphs, each edge is
|
199 |
201 |
/// represented by two opposite directed arcs.
|
200 |
202 |
class Edge : public GraphItem<'e'> {
|
201 |
203 |
typedef GraphItem<'e'> Parent;
|
202 |
204 |
|
203 |
205 |
public:
|
204 |
206 |
/// \brief Default constructor.
|
205 |
207 |
///
|
206 |
208 |
/// Default constructor.
|
207 |
209 |
/// \warning The default constructor is not required to set
|
208 |
210 |
/// the item to some well-defined value. So you should consider it
|
209 |
211 |
/// as uninitialized.
|
210 |
212 |
Edge() {}
|
211 |
213 |
|
212 |
214 |
/// \brief Copy constructor.
|
213 |
215 |
///
|
214 |
216 |
/// Copy constructor.
|
215 |
217 |
Edge(const Edge &) : Parent() {}
|
216 |
218 |
|
217 |
219 |
/// \brief Constructor for conversion from \c INVALID.
|
218 |
220 |
///
|
219 |
221 |
/// Constructor for conversion from \c INVALID.
|
220 |
222 |
/// It initializes the item to be invalid.
|
221 |
223 |
/// \sa Invalid for more details.
|
222 |
224 |
Edge(Invalid) {}
|
223 |
225 |
|
224 |
226 |
/// \brief Constructor for conversion from an arc.
|
... |
... |
@@ -245,392 +247,397 @@
|
245 |
247 |
/// represented edge.
|
246 |
248 |
Arc direct(const Edge&, bool) const { return INVALID; }
|
247 |
249 |
|
248 |
250 |
/// \brief Return a directed arc related to an edge.
|
249 |
251 |
///
|
250 |
252 |
/// This function returns a directed arc from its source node and the
|
251 |
253 |
/// represented edge.
|
252 |
254 |
Arc direct(const Edge&, const Node&) const { return INVALID; }
|
253 |
255 |
|
254 |
256 |
/// \brief Return the direction of the arc.
|
255 |
257 |
///
|
256 |
258 |
/// Returns the direction of the arc. Each arc represents an
|
257 |
259 |
/// edge with a direction. It gives back the
|
258 |
260 |
/// direction.
|
259 |
261 |
bool direction(const Arc&) const { return true; }
|
260 |
262 |
|
261 |
263 |
/// \brief Return the opposite arc.
|
262 |
264 |
///
|
263 |
265 |
/// This function returns the opposite arc, i.e. the arc representing
|
264 |
266 |
/// the same edge and has opposite direction.
|
265 |
267 |
Arc oppositeArc(const Arc&) const { return INVALID; }
|
266 |
268 |
|
267 |
269 |
template <typename _Graph>
|
268 |
270 |
struct Constraints {
|
269 |
271 |
typedef typename _Graph::Node Node;
|
270 |
272 |
typedef typename _Graph::Arc Arc;
|
271 |
273 |
typedef typename _Graph::Edge Edge;
|
272 |
274 |
|
273 |
275 |
void constraints() {
|
274 |
276 |
checkConcept<BaseDigraphComponent, _Graph>();
|
275 |
277 |
checkConcept<GraphItem<'e'>, Edge>();
|
276 |
278 |
{
|
277 |
279 |
Node n;
|
278 |
280 |
Edge ue(INVALID);
|
279 |
281 |
Arc e;
|
280 |
282 |
n = graph.u(ue);
|
281 |
283 |
n = graph.v(ue);
|
282 |
284 |
e = graph.direct(ue, true);
|
283 |
285 |
e = graph.direct(ue, false);
|
284 |
286 |
e = graph.direct(ue, n);
|
285 |
287 |
e = graph.oppositeArc(e);
|
286 |
288 |
ue = e;
|
287 |
289 |
bool d = graph.direction(e);
|
288 |
290 |
ignore_unused_variable_warning(d);
|
289 |
291 |
}
|
290 |
292 |
}
|
291 |
293 |
|
292 |
294 |
const _Graph& graph;
|
|
295 |
Constraints() {}
|
293 |
296 |
};
|
294 |
297 |
|
295 |
298 |
};
|
296 |
299 |
|
297 |
300 |
/// \brief Skeleton class for \e idable directed graphs.
|
298 |
301 |
///
|
299 |
302 |
/// This class describes the interface of \e idable directed graphs.
|
300 |
303 |
/// It extends \ref BaseDigraphComponent with the core ID functions.
|
301 |
304 |
/// The ids of the items must be unique and immutable.
|
302 |
305 |
/// This concept is part of the Digraph concept.
|
303 |
306 |
template <typename BAS = BaseDigraphComponent>
|
304 |
307 |
class IDableDigraphComponent : public BAS {
|
305 |
308 |
public:
|
306 |
309 |
|
307 |
310 |
typedef BAS Base;
|
308 |
311 |
typedef typename Base::Node Node;
|
309 |
312 |
typedef typename Base::Arc Arc;
|
310 |
313 |
|
311 |
314 |
/// \brief Return a unique integer id for the given node.
|
312 |
315 |
///
|
313 |
316 |
/// This function returns a unique integer id for the given node.
|
314 |
317 |
int id(const Node&) const { return -1; }
|
315 |
318 |
|
316 |
319 |
/// \brief Return the node by its unique id.
|
317 |
320 |
///
|
318 |
321 |
/// This function returns the node by its unique id.
|
319 |
322 |
/// If the digraph does not contain a node with the given id,
|
320 |
323 |
/// then the result of the function is undefined.
|
321 |
324 |
Node nodeFromId(int) const { return INVALID; }
|
322 |
325 |
|
323 |
326 |
/// \brief Return a unique integer id for the given arc.
|
324 |
327 |
///
|
325 |
328 |
/// This function returns a unique integer id for the given arc.
|
326 |
329 |
int id(const Arc&) const { return -1; }
|
327 |
330 |
|
328 |
331 |
/// \brief Return the arc by its unique id.
|
329 |
332 |
///
|
330 |
333 |
/// This function returns the arc by its unique id.
|
331 |
334 |
/// If the digraph does not contain an arc with the given id,
|
332 |
335 |
/// then the result of the function is undefined.
|
333 |
336 |
Arc arcFromId(int) const { return INVALID; }
|
334 |
337 |
|
335 |
338 |
/// \brief Return an integer greater or equal to the maximum
|
336 |
339 |
/// node id.
|
337 |
340 |
///
|
338 |
341 |
/// This function returns an integer greater or equal to the
|
339 |
342 |
/// maximum node id.
|
340 |
343 |
int maxNodeId() const { return -1; }
|
341 |
344 |
|
342 |
345 |
/// \brief Return an integer greater or equal to the maximum
|
343 |
346 |
/// arc id.
|
344 |
347 |
///
|
345 |
348 |
/// This function returns an integer greater or equal to the
|
346 |
349 |
/// maximum arc id.
|
347 |
350 |
int maxArcId() const { return -1; }
|
348 |
351 |
|
349 |
352 |
template <typename _Digraph>
|
350 |
353 |
struct Constraints {
|
351 |
354 |
|
352 |
355 |
void constraints() {
|
353 |
356 |
checkConcept<Base, _Digraph >();
|
354 |
357 |
typename _Digraph::Node node;
|
355 |
358 |
node=INVALID;
|
356 |
359 |
int nid = digraph.id(node);
|
357 |
360 |
nid = digraph.id(node);
|
358 |
361 |
node = digraph.nodeFromId(nid);
|
359 |
362 |
typename _Digraph::Arc arc;
|
360 |
363 |
arc=INVALID;
|
361 |
364 |
int eid = digraph.id(arc);
|
362 |
365 |
eid = digraph.id(arc);
|
363 |
366 |
arc = digraph.arcFromId(eid);
|
364 |
367 |
|
365 |
368 |
nid = digraph.maxNodeId();
|
366 |
369 |
ignore_unused_variable_warning(nid);
|
367 |
370 |
eid = digraph.maxArcId();
|
368 |
371 |
ignore_unused_variable_warning(eid);
|
369 |
372 |
}
|
370 |
373 |
|
371 |
374 |
const _Digraph& digraph;
|
|
375 |
Constraints() {}
|
372 |
376 |
};
|
373 |
377 |
};
|
374 |
378 |
|
375 |
379 |
/// \brief Skeleton class for \e idable undirected graphs.
|
376 |
380 |
///
|
377 |
381 |
/// This class describes the interface of \e idable undirected
|
378 |
382 |
/// graphs. It extends \ref IDableDigraphComponent with the core ID
|
379 |
383 |
/// functions of undirected graphs.
|
380 |
384 |
/// The ids of the items must be unique and immutable.
|
381 |
385 |
/// This concept is part of the Graph concept.
|
382 |
386 |
template <typename BAS = BaseGraphComponent>
|
383 |
387 |
class IDableGraphComponent : public IDableDigraphComponent<BAS> {
|
384 |
388 |
public:
|
385 |
389 |
|
386 |
390 |
typedef BAS Base;
|
387 |
391 |
typedef typename Base::Edge Edge;
|
388 |
392 |
|
389 |
393 |
using IDableDigraphComponent<Base>::id;
|
390 |
394 |
|
391 |
395 |
/// \brief Return a unique integer id for the given edge.
|
392 |
396 |
///
|
393 |
397 |
/// This function returns a unique integer id for the given edge.
|
394 |
398 |
int id(const Edge&) const { return -1; }
|
395 |
399 |
|
396 |
400 |
/// \brief Return the edge by its unique id.
|
397 |
401 |
///
|
398 |
402 |
/// This function returns the edge by its unique id.
|
399 |
403 |
/// If the graph does not contain an edge with the given id,
|
400 |
404 |
/// then the result of the function is undefined.
|
401 |
405 |
Edge edgeFromId(int) const { return INVALID; }
|
402 |
406 |
|
403 |
407 |
/// \brief Return an integer greater or equal to the maximum
|
404 |
408 |
/// edge id.
|
405 |
409 |
///
|
406 |
410 |
/// This function returns an integer greater or equal to the
|
407 |
411 |
/// maximum edge id.
|
408 |
412 |
int maxEdgeId() const { return -1; }
|
409 |
413 |
|
410 |
414 |
template <typename _Graph>
|
411 |
415 |
struct Constraints {
|
412 |
416 |
|
413 |
417 |
void constraints() {
|
414 |
418 |
checkConcept<IDableDigraphComponent<Base>, _Graph >();
|
415 |
419 |
typename _Graph::Edge edge;
|
416 |
420 |
int ueid = graph.id(edge);
|
417 |
421 |
ueid = graph.id(edge);
|
418 |
422 |
edge = graph.edgeFromId(ueid);
|
419 |
423 |
ueid = graph.maxEdgeId();
|
420 |
424 |
ignore_unused_variable_warning(ueid);
|
421 |
425 |
}
|
422 |
426 |
|
423 |
427 |
const _Graph& graph;
|
|
428 |
Constraints() {}
|
424 |
429 |
};
|
425 |
430 |
};
|
426 |
431 |
|
427 |
432 |
/// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
|
428 |
433 |
///
|
429 |
434 |
/// This class describes the concept of \c NodeIt, \c ArcIt and
|
430 |
435 |
/// \c EdgeIt subtypes of digraph and graph types.
|
431 |
436 |
template <typename GR, typename Item>
|
432 |
437 |
class GraphItemIt : public Item {
|
433 |
438 |
public:
|
434 |
439 |
/// \brief Default constructor.
|
435 |
440 |
///
|
436 |
441 |
/// Default constructor.
|
437 |
442 |
/// \warning The default constructor is not required to set
|
438 |
443 |
/// the iterator to some well-defined value. So you should consider it
|
439 |
444 |
/// as uninitialized.
|
440 |
445 |
GraphItemIt() {}
|
441 |
446 |
|
442 |
447 |
/// \brief Copy constructor.
|
443 |
448 |
///
|
444 |
449 |
/// Copy constructor.
|
445 |
450 |
GraphItemIt(const GraphItemIt& it) : Item(it) {}
|
446 |
451 |
|
447 |
452 |
/// \brief Constructor that sets the iterator to the first item.
|
448 |
453 |
///
|
449 |
454 |
/// Constructor that sets the iterator to the first item.
|
450 |
455 |
explicit GraphItemIt(const GR&) {}
|
451 |
456 |
|
452 |
457 |
/// \brief Constructor for conversion from \c INVALID.
|
453 |
458 |
///
|
454 |
459 |
/// Constructor for conversion from \c INVALID.
|
455 |
460 |
/// It initializes the iterator to be invalid.
|
456 |
461 |
/// \sa Invalid for more details.
|
457 |
462 |
GraphItemIt(Invalid) {}
|
458 |
463 |
|
459 |
464 |
/// \brief Assignment operator.
|
460 |
465 |
///
|
461 |
466 |
/// Assignment operator for the iterator.
|
462 |
467 |
GraphItemIt& operator=(const GraphItemIt&) { return *this; }
|
463 |
468 |
|
464 |
469 |
/// \brief Increment the iterator.
|
465 |
470 |
///
|
466 |
471 |
/// This operator increments the iterator, i.e. assigns it to the
|
467 |
472 |
/// next item.
|
468 |
473 |
GraphItemIt& operator++() { return *this; }
|
469 |
474 |
|
470 |
475 |
/// \brief Equality operator
|
471 |
476 |
///
|
472 |
477 |
/// Equality operator.
|
473 |
478 |
/// Two iterators are equal if and only if they point to the
|
474 |
479 |
/// same object or both are invalid.
|
475 |
480 |
bool operator==(const GraphItemIt&) const { return true;}
|
476 |
481 |
|
477 |
482 |
/// \brief Inequality operator
|
478 |
483 |
///
|
479 |
484 |
/// Inequality operator.
|
480 |
485 |
/// Two iterators are equal if and only if they point to the
|
481 |
486 |
/// same object or both are invalid.
|
482 |
487 |
bool operator!=(const GraphItemIt&) const { return true;}
|
483 |
488 |
|
484 |
489 |
template<typename _GraphItemIt>
|
485 |
490 |
struct Constraints {
|
486 |
491 |
void constraints() {
|
487 |
492 |
checkConcept<GraphItem<>, _GraphItemIt>();
|
488 |
493 |
_GraphItemIt it1(g);
|
489 |
494 |
_GraphItemIt it2;
|
490 |
495 |
_GraphItemIt it3 = it1;
|
491 |
496 |
_GraphItemIt it4 = INVALID;
|
492 |
497 |
|
493 |
498 |
it2 = ++it1;
|
494 |
499 |
++it2 = it1;
|
495 |
500 |
++(++it1);
|
496 |
501 |
|
497 |
502 |
Item bi = it1;
|
498 |
503 |
bi = it2;
|
499 |
504 |
}
|
500 |
505 |
const GR& g;
|
|
506 |
Constraints() {}
|
501 |
507 |
};
|
502 |
508 |
};
|
503 |
509 |
|
504 |
510 |
/// \brief Concept class for \c InArcIt, \c OutArcIt and
|
505 |
511 |
/// \c IncEdgeIt types.
|
506 |
512 |
///
|
507 |
513 |
/// This class describes the concept of \c InArcIt, \c OutArcIt
|
508 |
514 |
/// and \c IncEdgeIt subtypes of digraph and graph types.
|
509 |
515 |
///
|
510 |
516 |
/// \note Since these iterator classes do not inherit from the same
|
511 |
517 |
/// base class, there is an additional template parameter (selector)
|
512 |
518 |
/// \c sel. For \c InArcIt you should instantiate it with character
|
513 |
519 |
/// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
|
514 |
520 |
template <typename GR,
|
515 |
521 |
typename Item = typename GR::Arc,
|
516 |
522 |
typename Base = typename GR::Node,
|
517 |
523 |
char sel = '0'>
|
518 |
524 |
class GraphIncIt : public Item {
|
519 |
525 |
public:
|
520 |
526 |
/// \brief Default constructor.
|
521 |
527 |
///
|
522 |
528 |
/// Default constructor.
|
523 |
529 |
/// \warning The default constructor is not required to set
|
524 |
530 |
/// the iterator to some well-defined value. So you should consider it
|
525 |
531 |
/// as uninitialized.
|
526 |
532 |
GraphIncIt() {}
|
527 |
533 |
|
528 |
534 |
/// \brief Copy constructor.
|
529 |
535 |
///
|
530 |
536 |
/// Copy constructor.
|
531 |
537 |
GraphIncIt(const GraphIncIt& it) : Item(it) {}
|
532 |
538 |
|
533 |
539 |
/// \brief Constructor that sets the iterator to the first
|
534 |
540 |
/// incoming or outgoing arc.
|
535 |
541 |
///
|
536 |
542 |
/// Constructor that sets the iterator to the first arc
|
537 |
543 |
/// incoming to or outgoing from the given node.
|
538 |
544 |
explicit GraphIncIt(const GR&, const Base&) {}
|
539 |
545 |
|
540 |
546 |
/// \brief Constructor for conversion from \c INVALID.
|
541 |
547 |
///
|
542 |
548 |
/// Constructor for conversion from \c INVALID.
|
543 |
549 |
/// It initializes the iterator to be invalid.
|
544 |
550 |
/// \sa Invalid for more details.
|
545 |
551 |
GraphIncIt(Invalid) {}
|
546 |
552 |
|
547 |
553 |
/// \brief Assignment operator.
|
548 |
554 |
///
|
549 |
555 |
/// Assignment operator for the iterator.
|
550 |
556 |
GraphIncIt& operator=(const GraphIncIt&) { return *this; }
|
551 |
557 |
|
552 |
558 |
/// \brief Increment the iterator.
|
553 |
559 |
///
|
554 |
560 |
/// This operator increments the iterator, i.e. assigns it to the
|
555 |
561 |
/// next arc incoming to or outgoing from the given node.
|
556 |
562 |
GraphIncIt& operator++() { return *this; }
|
557 |
563 |
|
558 |
564 |
/// \brief Equality operator
|
559 |
565 |
///
|
560 |
566 |
/// Equality operator.
|
561 |
567 |
/// Two iterators are equal if and only if they point to the
|
562 |
568 |
/// same object or both are invalid.
|
563 |
569 |
bool operator==(const GraphIncIt&) const { return true;}
|
564 |
570 |
|
565 |
571 |
/// \brief Inequality operator
|
566 |
572 |
///
|
567 |
573 |
/// Inequality operator.
|
568 |
574 |
/// Two iterators are equal if and only if they point to the
|
569 |
575 |
/// same object or both are invalid.
|
570 |
576 |
bool operator!=(const GraphIncIt&) const { return true;}
|
571 |
577 |
|
572 |
578 |
template <typename _GraphIncIt>
|
573 |
579 |
struct Constraints {
|
574 |
580 |
void constraints() {
|
575 |
581 |
checkConcept<GraphItem<sel>, _GraphIncIt>();
|
576 |
582 |
_GraphIncIt it1(graph, node);
|
577 |
583 |
_GraphIncIt it2;
|
578 |
584 |
_GraphIncIt it3 = it1;
|
579 |
585 |
_GraphIncIt it4 = INVALID;
|
580 |
586 |
|
581 |
587 |
it2 = ++it1;
|
582 |
588 |
++it2 = it1;
|
583 |
589 |
++(++it1);
|
584 |
590 |
Item e = it1;
|
585 |
591 |
e = it2;
|
586 |
592 |
}
|
587 |
593 |
const Base& node;
|
588 |
594 |
const GR& graph;
|
|
595 |
Constraints() {}
|
589 |
596 |
};
|
590 |
597 |
};
|
591 |
598 |
|
592 |
599 |
/// \brief Skeleton class for iterable directed graphs.
|
593 |
600 |
///
|
594 |
601 |
/// This class describes the interface of iterable directed
|
595 |
602 |
/// graphs. It extends \ref BaseDigraphComponent with the core
|
596 |
603 |
/// iterable interface.
|
597 |
604 |
/// This concept is part of the Digraph concept.
|
598 |
605 |
template <typename BAS = BaseDigraphComponent>
|
599 |
606 |
class IterableDigraphComponent : public BAS {
|
600 |
607 |
|
601 |
608 |
public:
|
602 |
609 |
|
603 |
610 |
typedef BAS Base;
|
604 |
611 |
typedef typename Base::Node Node;
|
605 |
612 |
typedef typename Base::Arc Arc;
|
606 |
613 |
|
607 |
614 |
typedef IterableDigraphComponent Digraph;
|
608 |
615 |
|
609 |
616 |
/// \name Base Iteration
|
610 |
617 |
///
|
611 |
618 |
/// This interface provides functions for iteration on digraph items.
|
612 |
619 |
///
|
613 |
620 |
/// @{
|
614 |
621 |
|
615 |
622 |
/// \brief Return the first node.
|
616 |
623 |
///
|
617 |
624 |
/// This function gives back the first node in the iteration order.
|
618 |
625 |
void first(Node&) const {}
|
619 |
626 |
|
620 |
627 |
/// \brief Return the next node.
|
621 |
628 |
///
|
622 |
629 |
/// This function gives back the next node in the iteration order.
|
623 |
630 |
void next(Node&) const {}
|
624 |
631 |
|
625 |
632 |
/// \brief Return the first arc.
|
626 |
633 |
///
|
627 |
634 |
/// This function gives back the first arc in the iteration order.
|
628 |
635 |
void first(Arc&) const {}
|
629 |
636 |
|
630 |
637 |
/// \brief Return the next arc.
|
631 |
638 |
///
|
632 |
639 |
/// This function gives back the next arc in the iteration order.
|
633 |
640 |
void next(Arc&) const {}
|
634 |
641 |
|
635 |
642 |
/// \brief Return the first arc incomming to the given node.
|
636 |
643 |
///
|
... |
... |
@@ -717,96 +724,97 @@
|
717 |
724 |
template <typename _Digraph>
|
718 |
725 |
struct Constraints {
|
719 |
726 |
void constraints() {
|
720 |
727 |
checkConcept<Base, _Digraph>();
|
721 |
728 |
|
722 |
729 |
{
|
723 |
730 |
typename _Digraph::Node node(INVALID);
|
724 |
731 |
typename _Digraph::Arc arc(INVALID);
|
725 |
732 |
{
|
726 |
733 |
digraph.first(node);
|
727 |
734 |
digraph.next(node);
|
728 |
735 |
}
|
729 |
736 |
{
|
730 |
737 |
digraph.first(arc);
|
731 |
738 |
digraph.next(arc);
|
732 |
739 |
}
|
733 |
740 |
{
|
734 |
741 |
digraph.firstIn(arc, node);
|
735 |
742 |
digraph.nextIn(arc);
|
736 |
743 |
}
|
737 |
744 |
{
|
738 |
745 |
digraph.firstOut(arc, node);
|
739 |
746 |
digraph.nextOut(arc);
|
740 |
747 |
}
|
741 |
748 |
}
|
742 |
749 |
|
743 |
750 |
{
|
744 |
751 |
checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
|
745 |
752 |
typename _Digraph::ArcIt >();
|
746 |
753 |
checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
|
747 |
754 |
typename _Digraph::NodeIt >();
|
748 |
755 |
checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
|
749 |
756 |
typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
|
750 |
757 |
checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
|
751 |
758 |
typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
|
752 |
759 |
|
753 |
760 |
typename _Digraph::Node n;
|
754 |
761 |
const typename _Digraph::InArcIt iait(INVALID);
|
755 |
762 |
const typename _Digraph::OutArcIt oait(INVALID);
|
756 |
763 |
n = digraph.baseNode(iait);
|
757 |
764 |
n = digraph.runningNode(iait);
|
758 |
765 |
n = digraph.baseNode(oait);
|
759 |
766 |
n = digraph.runningNode(oait);
|
760 |
767 |
ignore_unused_variable_warning(n);
|
761 |
768 |
}
|
762 |
769 |
}
|
763 |
770 |
|
764 |
771 |
const _Digraph& digraph;
|
|
772 |
Constraints() {}
|
765 |
773 |
};
|
766 |
774 |
};
|
767 |
775 |
|
768 |
776 |
/// \brief Skeleton class for iterable undirected graphs.
|
769 |
777 |
///
|
770 |
778 |
/// This class describes the interface of iterable undirected
|
771 |
779 |
/// graphs. It extends \ref IterableDigraphComponent with the core
|
772 |
780 |
/// iterable interface of undirected graphs.
|
773 |
781 |
/// This concept is part of the Graph concept.
|
774 |
782 |
template <typename BAS = BaseGraphComponent>
|
775 |
783 |
class IterableGraphComponent : public IterableDigraphComponent<BAS> {
|
776 |
784 |
public:
|
777 |
785 |
|
778 |
786 |
typedef BAS Base;
|
779 |
787 |
typedef typename Base::Node Node;
|
780 |
788 |
typedef typename Base::Arc Arc;
|
781 |
789 |
typedef typename Base::Edge Edge;
|
782 |
790 |
|
783 |
791 |
|
784 |
792 |
typedef IterableGraphComponent Graph;
|
785 |
793 |
|
786 |
794 |
/// \name Base Iteration
|
787 |
795 |
///
|
788 |
796 |
/// This interface provides functions for iteration on edges.
|
789 |
797 |
///
|
790 |
798 |
/// @{
|
791 |
799 |
|
792 |
800 |
using IterableDigraphComponent<Base>::first;
|
793 |
801 |
using IterableDigraphComponent<Base>::next;
|
794 |
802 |
|
795 |
803 |
/// \brief Return the first edge.
|
796 |
804 |
///
|
797 |
805 |
/// This function gives back the first edge in the iteration order.
|
798 |
806 |
void first(Edge&) const {}
|
799 |
807 |
|
800 |
808 |
/// \brief Return the next edge.
|
801 |
809 |
///
|
802 |
810 |
/// This function gives back the next edge in the iteration order.
|
803 |
811 |
void next(Edge&) const {}
|
804 |
812 |
|
805 |
813 |
/// \brief Return the first edge incident to the given node.
|
806 |
814 |
///
|
807 |
815 |
/// This function gives back the first edge incident to the given
|
808 |
816 |
/// node. The bool parameter gives back the direction for which the
|
809 |
817 |
/// source node of the directed arc representing the edge is the
|
810 |
818 |
/// given node.
|
811 |
819 |
void firstInc(Edge&, bool&, const Node&) const {}
|
812 |
820 |
|
... |
... |
@@ -841,271 +849,275 @@
|
841 |
849 |
typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
|
842 |
850 |
|
843 |
851 |
/// \brief The base node of the iterator.
|
844 |
852 |
///
|
845 |
853 |
/// This function gives back the base node of the iterator.
|
846 |
854 |
Node baseNode(const IncEdgeIt&) const { return INVALID; }
|
847 |
855 |
|
848 |
856 |
/// \brief The running node of the iterator.
|
849 |
857 |
///
|
850 |
858 |
/// This function gives back the running node of the iterator.
|
851 |
859 |
Node runningNode(const IncEdgeIt&) const { return INVALID; }
|
852 |
860 |
|
853 |
861 |
/// @}
|
854 |
862 |
|
855 |
863 |
template <typename _Graph>
|
856 |
864 |
struct Constraints {
|
857 |
865 |
void constraints() {
|
858 |
866 |
checkConcept<IterableDigraphComponent<Base>, _Graph>();
|
859 |
867 |
|
860 |
868 |
{
|
861 |
869 |
typename _Graph::Node node(INVALID);
|
862 |
870 |
typename _Graph::Edge edge(INVALID);
|
863 |
871 |
bool dir;
|
864 |
872 |
{
|
865 |
873 |
graph.first(edge);
|
866 |
874 |
graph.next(edge);
|
867 |
875 |
}
|
868 |
876 |
{
|
869 |
877 |
graph.firstInc(edge, dir, node);
|
870 |
878 |
graph.nextInc(edge, dir);
|
871 |
879 |
}
|
872 |
880 |
|
873 |
881 |
}
|
874 |
882 |
|
875 |
883 |
{
|
876 |
884 |
checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
|
877 |
885 |
typename _Graph::EdgeIt >();
|
878 |
886 |
checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
|
879 |
887 |
typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
|
880 |
888 |
|
881 |
889 |
typename _Graph::Node n;
|
882 |
890 |
const typename _Graph::IncEdgeIt ieit(INVALID);
|
883 |
891 |
n = graph.baseNode(ieit);
|
884 |
892 |
n = graph.runningNode(ieit);
|
885 |
893 |
}
|
886 |
894 |
}
|
887 |
895 |
|
888 |
896 |
const _Graph& graph;
|
|
897 |
Constraints() {}
|
889 |
898 |
};
|
890 |
899 |
};
|
891 |
900 |
|
892 |
901 |
/// \brief Skeleton class for alterable directed graphs.
|
893 |
902 |
///
|
894 |
903 |
/// This class describes the interface of alterable directed
|
895 |
904 |
/// graphs. It extends \ref BaseDigraphComponent with the alteration
|
896 |
905 |
/// notifier interface. It implements
|
897 |
906 |
/// an observer-notifier pattern for each digraph item. More
|
898 |
907 |
/// obsevers can be registered into the notifier and whenever an
|
899 |
908 |
/// alteration occured in the digraph all the observers will be
|
900 |
909 |
/// notified about it.
|
901 |
910 |
template <typename BAS = BaseDigraphComponent>
|
902 |
911 |
class AlterableDigraphComponent : public BAS {
|
903 |
912 |
public:
|
904 |
913 |
|
905 |
914 |
typedef BAS Base;
|
906 |
915 |
typedef typename Base::Node Node;
|
907 |
916 |
typedef typename Base::Arc Arc;
|
908 |
917 |
|
909 |
918 |
|
910 |
919 |
/// Node alteration notifier class.
|
911 |
920 |
typedef AlterationNotifier<AlterableDigraphComponent, Node>
|
912 |
921 |
NodeNotifier;
|
913 |
922 |
/// Arc alteration notifier class.
|
914 |
923 |
typedef AlterationNotifier<AlterableDigraphComponent, Arc>
|
915 |
924 |
ArcNotifier;
|
916 |
925 |
|
917 |
926 |
/// \brief Return the node alteration notifier.
|
918 |
927 |
///
|
919 |
928 |
/// This function gives back the node alteration notifier.
|
920 |
929 |
NodeNotifier& notifier(Node) const {
|
921 |
930 |
return NodeNotifier();
|
922 |
931 |
}
|
923 |
932 |
|
924 |
933 |
/// \brief Return the arc alteration notifier.
|
925 |
934 |
///
|
926 |
935 |
/// This function gives back the arc alteration notifier.
|
927 |
936 |
ArcNotifier& notifier(Arc) const {
|
928 |
937 |
return ArcNotifier();
|
929 |
938 |
}
|
930 |
939 |
|
931 |
940 |
template <typename _Digraph>
|
932 |
941 |
struct Constraints {
|
933 |
942 |
void constraints() {
|
934 |
943 |
checkConcept<Base, _Digraph>();
|
935 |
944 |
typename _Digraph::NodeNotifier& nn
|
936 |
945 |
= digraph.notifier(typename _Digraph::Node());
|
937 |
946 |
|
938 |
947 |
typename _Digraph::ArcNotifier& en
|
939 |
948 |
= digraph.notifier(typename _Digraph::Arc());
|
940 |
949 |
|
941 |
950 |
ignore_unused_variable_warning(nn);
|
942 |
951 |
ignore_unused_variable_warning(en);
|
943 |
952 |
}
|
944 |
953 |
|
945 |
954 |
const _Digraph& digraph;
|
|
955 |
Constraints() {}
|
946 |
956 |
};
|
947 |
957 |
};
|
948 |
958 |
|
949 |
959 |
/// \brief Skeleton class for alterable undirected graphs.
|
950 |
960 |
///
|
951 |
961 |
/// This class describes the interface of alterable undirected
|
952 |
962 |
/// graphs. It extends \ref AlterableDigraphComponent with the alteration
|
953 |
963 |
/// notifier interface of undirected graphs. It implements
|
954 |
964 |
/// an observer-notifier pattern for the edges. More
|
955 |
965 |
/// obsevers can be registered into the notifier and whenever an
|
956 |
966 |
/// alteration occured in the graph all the observers will be
|
957 |
967 |
/// notified about it.
|
958 |
968 |
template <typename BAS = BaseGraphComponent>
|
959 |
969 |
class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
|
960 |
970 |
public:
|
961 |
971 |
|
962 |
972 |
typedef BAS Base;
|
963 |
973 |
typedef typename Base::Edge Edge;
|
964 |
974 |
|
965 |
975 |
|
966 |
976 |
/// Edge alteration notifier class.
|
967 |
977 |
typedef AlterationNotifier<AlterableGraphComponent, Edge>
|
968 |
978 |
EdgeNotifier;
|
969 |
979 |
|
970 |
980 |
/// \brief Return the edge alteration notifier.
|
971 |
981 |
///
|
972 |
982 |
/// This function gives back the edge alteration notifier.
|
973 |
983 |
EdgeNotifier& notifier(Edge) const {
|
974 |
984 |
return EdgeNotifier();
|
975 |
985 |
}
|
976 |
986 |
|
977 |
987 |
template <typename _Graph>
|
978 |
988 |
struct Constraints {
|
979 |
989 |
void constraints() {
|
980 |
990 |
checkConcept<AlterableDigraphComponent<Base>, _Graph>();
|
981 |
991 |
typename _Graph::EdgeNotifier& uen
|
982 |
992 |
= graph.notifier(typename _Graph::Edge());
|
983 |
993 |
ignore_unused_variable_warning(uen);
|
984 |
994 |
}
|
985 |
995 |
|
986 |
996 |
const _Graph& graph;
|
|
997 |
Constraints() {}
|
987 |
998 |
};
|
988 |
999 |
};
|
989 |
1000 |
|
990 |
1001 |
/// \brief Concept class for standard graph maps.
|
991 |
1002 |
///
|
992 |
1003 |
/// This class describes the concept of standard graph maps, i.e.
|
993 |
1004 |
/// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
|
994 |
1005 |
/// graph types, which can be used for associating data to graph items.
|
995 |
1006 |
/// The standard graph maps must conform to the ReferenceMap concept.
|
996 |
1007 |
template <typename GR, typename K, typename V>
|
997 |
1008 |
class GraphMap : public ReferenceMap<K, V, V&, const V&> {
|
998 |
1009 |
typedef ReferenceMap<K, V, V&, const V&> Parent;
|
999 |
1010 |
|
1000 |
1011 |
public:
|
1001 |
1012 |
|
1002 |
1013 |
/// The key type of the map.
|
1003 |
1014 |
typedef K Key;
|
1004 |
1015 |
/// The value type of the map.
|
1005 |
1016 |
typedef V Value;
|
1006 |
1017 |
/// The reference type of the map.
|
1007 |
1018 |
typedef Value& Reference;
|
1008 |
1019 |
/// The const reference type of the map.
|
1009 |
1020 |
typedef const Value& ConstReference;
|
1010 |
1021 |
|
1011 |
1022 |
// The reference map tag.
|
1012 |
1023 |
typedef True ReferenceMapTag;
|
1013 |
1024 |
|
1014 |
1025 |
/// \brief Construct a new map.
|
1015 |
1026 |
///
|
1016 |
1027 |
/// Construct a new map for the graph.
|
1017 |
1028 |
explicit GraphMap(const GR&) {}
|
1018 |
1029 |
/// \brief Construct a new map with default value.
|
1019 |
1030 |
///
|
1020 |
1031 |
/// Construct a new map for the graph and initalize the values.
|
1021 |
1032 |
GraphMap(const GR&, const Value&) {}
|
1022 |
1033 |
|
1023 |
1034 |
private:
|
1024 |
1035 |
/// \brief Copy constructor.
|
1025 |
1036 |
///
|
1026 |
1037 |
/// Copy Constructor.
|
1027 |
1038 |
GraphMap(const GraphMap&) : Parent() {}
|
1028 |
1039 |
|
1029 |
1040 |
/// \brief Assignment operator.
|
1030 |
1041 |
///
|
1031 |
1042 |
/// Assignment operator. It does not mofify the underlying graph,
|
1032 |
1043 |
/// it just iterates on the current item set and set the map
|
1033 |
1044 |
/// with the value returned by the assigned map.
|
1034 |
1045 |
template <typename CMap>
|
1035 |
1046 |
GraphMap& operator=(const CMap&) {
|
1036 |
1047 |
checkConcept<ReadMap<Key, Value>, CMap>();
|
1037 |
1048 |
return *this;
|
1038 |
1049 |
}
|
1039 |
1050 |
|
1040 |
1051 |
public:
|
1041 |
1052 |
template<typename _Map>
|
1042 |
1053 |
struct Constraints {
|
1043 |
1054 |
void constraints() {
|
1044 |
1055 |
checkConcept
|
1045 |
1056 |
<ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
|
1046 |
1057 |
_Map m1(g);
|
1047 |
1058 |
_Map m2(g,t);
|
1048 |
1059 |
|
1049 |
1060 |
// Copy constructor
|
1050 |
1061 |
// _Map m3(m);
|
1051 |
1062 |
|
1052 |
1063 |
// Assignment operator
|
1053 |
1064 |
// ReadMap<Key, Value> cmap;
|
1054 |
1065 |
// m3 = cmap;
|
1055 |
1066 |
|
1056 |
1067 |
ignore_unused_variable_warning(m1);
|
1057 |
1068 |
ignore_unused_variable_warning(m2);
|
1058 |
1069 |
// ignore_unused_variable_warning(m3);
|
1059 |
1070 |
}
|
1060 |
1071 |
|
1061 |
1072 |
const _Map &m;
|
1062 |
1073 |
const GR &g;
|
1063 |
1074 |
const typename GraphMap::Value &t;
|
|
1075 |
Constraints() {}
|
1064 |
1076 |
};
|
1065 |
1077 |
|
1066 |
1078 |
};
|
1067 |
1079 |
|
1068 |
1080 |
/// \brief Skeleton class for mappable directed graphs.
|
1069 |
1081 |
///
|
1070 |
1082 |
/// This class describes the interface of mappable directed graphs.
|
1071 |
1083 |
/// It extends \ref BaseDigraphComponent with the standard digraph
|
1072 |
1084 |
/// map classes, namely \c NodeMap and \c ArcMap.
|
1073 |
1085 |
/// This concept is part of the Digraph concept.
|
1074 |
1086 |
template <typename BAS = BaseDigraphComponent>
|
1075 |
1087 |
class MappableDigraphComponent : public BAS {
|
1076 |
1088 |
public:
|
1077 |
1089 |
|
1078 |
1090 |
typedef BAS Base;
|
1079 |
1091 |
typedef typename Base::Node Node;
|
1080 |
1092 |
typedef typename Base::Arc Arc;
|
1081 |
1093 |
|
1082 |
1094 |
typedef MappableDigraphComponent Digraph;
|
1083 |
1095 |
|
1084 |
1096 |
/// \brief Standard graph map for the nodes.
|
1085 |
1097 |
///
|
1086 |
1098 |
/// Standard graph map for the nodes.
|
1087 |
1099 |
/// It conforms to the ReferenceMap concept.
|
1088 |
1100 |
template <typename V>
|
1089 |
1101 |
class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
|
1090 |
1102 |
typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
|
1091 |
1103 |
|
1092 |
1104 |
public:
|
1093 |
1105 |
/// \brief Construct a new map.
|
1094 |
1106 |
///
|
1095 |
1107 |
/// Construct a new map for the digraph.
|
1096 |
1108 |
explicit NodeMap(const MappableDigraphComponent& digraph)
|
1097 |
1109 |
: Parent(digraph) {}
|
1098 |
1110 |
|
1099 |
1111 |
/// \brief Construct a new map with default value.
|
1100 |
1112 |
///
|
1101 |
1113 |
/// Construct a new map for the digraph and initalize the values.
|
1102 |
1114 |
NodeMap(const MappableDigraphComponent& digraph, const V& value)
|
1103 |
1115 |
: Parent(digraph, value) {}
|
1104 |
1116 |
|
1105 |
1117 |
private:
|
1106 |
1118 |
/// \brief Copy constructor.
|
1107 |
1119 |
///
|
1108 |
1120 |
/// Copy Constructor.
|
1109 |
1121 |
NodeMap(const NodeMap& nm) : Parent(nm) {}
|
1110 |
1122 |
|
1111 |
1123 |
/// \brief Assignment operator.
|
... |
... |
@@ -1154,363 +1166,371 @@
|
1154 |
1166 |
checkConcept<ReadMap<Arc, V>, CMap>();
|
1155 |
1167 |
return *this;
|
1156 |
1168 |
}
|
1157 |
1169 |
|
1158 |
1170 |
};
|
1159 |
1171 |
|
1160 |
1172 |
|
1161 |
1173 |
template <typename _Digraph>
|
1162 |
1174 |
struct Constraints {
|
1163 |
1175 |
|
1164 |
1176 |
struct Dummy {
|
1165 |
1177 |
int value;
|
1166 |
1178 |
Dummy() : value(0) {}
|
1167 |
1179 |
Dummy(int _v) : value(_v) {}
|
1168 |
1180 |
};
|
1169 |
1181 |
|
1170 |
1182 |
void constraints() {
|
1171 |
1183 |
checkConcept<Base, _Digraph>();
|
1172 |
1184 |
{ // int map test
|
1173 |
1185 |
typedef typename _Digraph::template NodeMap<int> IntNodeMap;
|
1174 |
1186 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
|
1175 |
1187 |
IntNodeMap >();
|
1176 |
1188 |
} { // bool map test
|
1177 |
1189 |
typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
|
1178 |
1190 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
|
1179 |
1191 |
BoolNodeMap >();
|
1180 |
1192 |
} { // Dummy map test
|
1181 |
1193 |
typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
|
1182 |
1194 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
|
1183 |
1195 |
DummyNodeMap >();
|
1184 |
1196 |
}
|
1185 |
1197 |
|
1186 |
1198 |
{ // int map test
|
1187 |
1199 |
typedef typename _Digraph::template ArcMap<int> IntArcMap;
|
1188 |
1200 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
|
1189 |
1201 |
IntArcMap >();
|
1190 |
1202 |
} { // bool map test
|
1191 |
1203 |
typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
|
1192 |
1204 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
|
1193 |
1205 |
BoolArcMap >();
|
1194 |
1206 |
} { // Dummy map test
|
1195 |
1207 |
typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
|
1196 |
1208 |
checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
|
1197 |
1209 |
DummyArcMap >();
|
1198 |
1210 |
}
|
1199 |
1211 |
}
|
1200 |
1212 |
|
1201 |
1213 |
const _Digraph& digraph;
|
|
1214 |
Constraints() {}
|
1202 |
1215 |
};
|
1203 |
1216 |
};
|
1204 |
1217 |
|
1205 |
1218 |
/// \brief Skeleton class for mappable undirected graphs.
|
1206 |
1219 |
///
|
1207 |
1220 |
/// This class describes the interface of mappable undirected graphs.
|
1208 |
1221 |
/// It extends \ref MappableDigraphComponent with the standard graph
|
1209 |
1222 |
/// map class for edges (\c EdgeMap).
|
1210 |
1223 |
/// This concept is part of the Graph concept.
|
1211 |
1224 |
template <typename BAS = BaseGraphComponent>
|
1212 |
1225 |
class MappableGraphComponent : public MappableDigraphComponent<BAS> {
|
1213 |
1226 |
public:
|
1214 |
1227 |
|
1215 |
1228 |
typedef BAS Base;
|
1216 |
1229 |
typedef typename Base::Edge Edge;
|
1217 |
1230 |
|
1218 |
1231 |
typedef MappableGraphComponent Graph;
|
1219 |
1232 |
|
1220 |
1233 |
/// \brief Standard graph map for the edges.
|
1221 |
1234 |
///
|
1222 |
1235 |
/// Standard graph map for the edges.
|
1223 |
1236 |
/// It conforms to the ReferenceMap concept.
|
1224 |
1237 |
template <typename V>
|
1225 |
1238 |
class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
|
1226 |
1239 |
typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
|
1227 |
1240 |
|
1228 |
1241 |
public:
|
1229 |
1242 |
/// \brief Construct a new map.
|
1230 |
1243 |
///
|
1231 |
1244 |
/// Construct a new map for the graph.
|
1232 |
1245 |
explicit EdgeMap(const MappableGraphComponent& graph)
|
1233 |
1246 |
: Parent(graph) {}
|
1234 |
1247 |
|
1235 |
1248 |
/// \brief Construct a new map with default value.
|
1236 |
1249 |
///
|
1237 |
1250 |
/// Construct a new map for the graph and initalize the values.
|
1238 |
1251 |
EdgeMap(const MappableGraphComponent& graph, const V& value)
|
1239 |
1252 |
: Parent(graph, value) {}
|
1240 |
1253 |
|
1241 |
1254 |
private:
|
1242 |
1255 |
/// \brief Copy constructor.
|
1243 |
1256 |
///
|
1244 |
1257 |
/// Copy Constructor.
|
1245 |
1258 |
EdgeMap(const EdgeMap& nm) : Parent(nm) {}
|
1246 |
1259 |
|
1247 |
1260 |
/// \brief Assignment operator.
|
1248 |
1261 |
///
|
1249 |
1262 |
/// Assignment operator.
|
1250 |
1263 |
template <typename CMap>
|
1251 |
1264 |
EdgeMap& operator=(const CMap&) {
|
1252 |
1265 |
checkConcept<ReadMap<Edge, V>, CMap>();
|
1253 |
1266 |
return *this;
|
1254 |
1267 |
}
|
1255 |
1268 |
|
1256 |
1269 |
};
|
1257 |
1270 |
|
1258 |
1271 |
|
1259 |
1272 |
template <typename _Graph>
|
1260 |
1273 |
struct Constraints {
|
1261 |
1274 |
|
1262 |
1275 |
struct Dummy {
|
1263 |
1276 |
int value;
|
1264 |
1277 |
Dummy() : value(0) {}
|
1265 |
1278 |
Dummy(int _v) : value(_v) {}
|
1266 |
1279 |
};
|
1267 |
1280 |
|
1268 |
1281 |
void constraints() {
|
1269 |
1282 |
checkConcept<MappableDigraphComponent<Base>, _Graph>();
|
1270 |
1283 |
|
1271 |
1284 |
{ // int map test
|
1272 |
1285 |
typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
|
1273 |
1286 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
|
1274 |
1287 |
IntEdgeMap >();
|
1275 |
1288 |
} { // bool map test
|
1276 |
1289 |
typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
|
1277 |
1290 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
|
1278 |
1291 |
BoolEdgeMap >();
|
1279 |
1292 |
} { // Dummy map test
|
1280 |
1293 |
typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
|
1281 |
1294 |
checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
|
1282 |
1295 |
DummyEdgeMap >();
|
1283 |
1296 |
}
|
1284 |
1297 |
}
|
1285 |
1298 |
|
1286 |
1299 |
const _Graph& graph;
|
|
1300 |
Constraints() {}
|
1287 |
1301 |
};
|
1288 |
1302 |
};
|
1289 |
1303 |
|
1290 |
1304 |
/// \brief Skeleton class for extendable directed graphs.
|
1291 |
1305 |
///
|
1292 |
1306 |
/// This class describes the interface of extendable directed graphs.
|
1293 |
1307 |
/// It extends \ref BaseDigraphComponent with functions for adding
|
1294 |
1308 |
/// nodes and arcs to the digraph.
|
1295 |
1309 |
/// This concept requires \ref AlterableDigraphComponent.
|
1296 |
1310 |
template <typename BAS = BaseDigraphComponent>
|
1297 |
1311 |
class ExtendableDigraphComponent : public BAS {
|
1298 |
1312 |
public:
|
1299 |
1313 |
typedef BAS Base;
|
1300 |
1314 |
|
1301 |
1315 |
typedef typename Base::Node Node;
|
1302 |
1316 |
typedef typename Base::Arc Arc;
|
1303 |
1317 |
|
1304 |
1318 |
/// \brief Add a new node to the digraph.
|
1305 |
1319 |
///
|
1306 |
1320 |
/// This function adds a new node to the digraph.
|
1307 |
1321 |
Node addNode() {
|
1308 |
1322 |
return INVALID;
|
1309 |
1323 |
}
|
1310 |
1324 |
|
1311 |
1325 |
/// \brief Add a new arc connecting the given two nodes.
|
1312 |
1326 |
///
|
1313 |
1327 |
/// This function adds a new arc connecting the given two nodes
|
1314 |
1328 |
/// of the digraph.
|
1315 |
1329 |
Arc addArc(const Node&, const Node&) {
|
1316 |
1330 |
return INVALID;
|
1317 |
1331 |
}
|
1318 |
1332 |
|
1319 |
1333 |
template <typename _Digraph>
|
1320 |
1334 |
struct Constraints {
|
1321 |
1335 |
void constraints() {
|
1322 |
1336 |
checkConcept<Base, _Digraph>();
|
1323 |
1337 |
typename _Digraph::Node node_a, node_b;
|
1324 |
1338 |
node_a = digraph.addNode();
|
1325 |
1339 |
node_b = digraph.addNode();
|
1326 |
1340 |
typename _Digraph::Arc arc;
|
1327 |
1341 |
arc = digraph.addArc(node_a, node_b);
|
1328 |
1342 |
}
|
1329 |
1343 |
|
1330 |
1344 |
_Digraph& digraph;
|
|
1345 |
Constraints() {}
|
1331 |
1346 |
};
|
1332 |
1347 |
};
|
1333 |
1348 |
|
1334 |
1349 |
/// \brief Skeleton class for extendable undirected graphs.
|
1335 |
1350 |
///
|
1336 |
1351 |
/// This class describes the interface of extendable undirected graphs.
|
1337 |
1352 |
/// It extends \ref BaseGraphComponent with functions for adding
|
1338 |
1353 |
/// nodes and edges to the graph.
|
1339 |
1354 |
/// This concept requires \ref AlterableGraphComponent.
|
1340 |
1355 |
template <typename BAS = BaseGraphComponent>
|
1341 |
1356 |
class ExtendableGraphComponent : public BAS {
|
1342 |
1357 |
public:
|
1343 |
1358 |
|
1344 |
1359 |
typedef BAS Base;
|
1345 |
1360 |
typedef typename Base::Node Node;
|
1346 |
1361 |
typedef typename Base::Edge Edge;
|
1347 |
1362 |
|
1348 |
1363 |
/// \brief Add a new node to the digraph.
|
1349 |
1364 |
///
|
1350 |
1365 |
/// This function adds a new node to the digraph.
|
1351 |
1366 |
Node addNode() {
|
1352 |
1367 |
return INVALID;
|
1353 |
1368 |
}
|
1354 |
1369 |
|
1355 |
1370 |
/// \brief Add a new edge connecting the given two nodes.
|
1356 |
1371 |
///
|
1357 |
1372 |
/// This function adds a new edge connecting the given two nodes
|
1358 |
1373 |
/// of the graph.
|
1359 |
1374 |
Edge addEdge(const Node&, const Node&) {
|
1360 |
1375 |
return INVALID;
|
1361 |
1376 |
}
|
1362 |
1377 |
|
1363 |
1378 |
template <typename _Graph>
|
1364 |
1379 |
struct Constraints {
|
1365 |
1380 |
void constraints() {
|
1366 |
1381 |
checkConcept<Base, _Graph>();
|
1367 |
1382 |
typename _Graph::Node node_a, node_b;
|
1368 |
1383 |
node_a = graph.addNode();
|
1369 |
1384 |
node_b = graph.addNode();
|
1370 |
1385 |
typename _Graph::Edge edge;
|
1371 |
1386 |
edge = graph.addEdge(node_a, node_b);
|
1372 |
1387 |
}
|
1373 |
1388 |
|
1374 |
1389 |
_Graph& graph;
|
|
1390 |
Constraints() {}
|
1375 |
1391 |
};
|
1376 |
1392 |
};
|
1377 |
1393 |
|
1378 |
1394 |
/// \brief Skeleton class for erasable directed graphs.
|
1379 |
1395 |
///
|
1380 |
1396 |
/// This class describes the interface of erasable directed graphs.
|
1381 |
1397 |
/// It extends \ref BaseDigraphComponent with functions for removing
|
1382 |
1398 |
/// nodes and arcs from the digraph.
|
1383 |
1399 |
/// This concept requires \ref AlterableDigraphComponent.
|
1384 |
1400 |
template <typename BAS = BaseDigraphComponent>
|
1385 |
1401 |
class ErasableDigraphComponent : public BAS {
|
1386 |
1402 |
public:
|
1387 |
1403 |
|
1388 |
1404 |
typedef BAS Base;
|
1389 |
1405 |
typedef typename Base::Node Node;
|
1390 |
1406 |
typedef typename Base::Arc Arc;
|
1391 |
1407 |
|
1392 |
1408 |
/// \brief Erase a node from the digraph.
|
1393 |
1409 |
///
|
1394 |
1410 |
/// This function erases the given node from the digraph and all arcs
|
1395 |
1411 |
/// connected to the node.
|
1396 |
1412 |
void erase(const Node&) {}
|
1397 |
1413 |
|
1398 |
1414 |
/// \brief Erase an arc from the digraph.
|
1399 |
1415 |
///
|
1400 |
1416 |
/// This function erases the given arc from the digraph.
|
1401 |
1417 |
void erase(const Arc&) {}
|
1402 |
1418 |
|
1403 |
1419 |
template <typename _Digraph>
|
1404 |
1420 |
struct Constraints {
|
1405 |
1421 |
void constraints() {
|
1406 |
1422 |
checkConcept<Base, _Digraph>();
|
1407 |
1423 |
const typename _Digraph::Node node(INVALID);
|
1408 |
1424 |
digraph.erase(node);
|
1409 |
1425 |
const typename _Digraph::Arc arc(INVALID);
|
1410 |
1426 |
digraph.erase(arc);
|
1411 |
1427 |
}
|
1412 |
1428 |
|
1413 |
1429 |
_Digraph& digraph;
|
|
1430 |
Constraints() {}
|
1414 |
1431 |
};
|
1415 |
1432 |
};
|
1416 |
1433 |
|
1417 |
1434 |
/// \brief Skeleton class for erasable undirected graphs.
|
1418 |
1435 |
///
|
1419 |
1436 |
/// This class describes the interface of erasable undirected graphs.
|
1420 |
1437 |
/// It extends \ref BaseGraphComponent with functions for removing
|
1421 |
1438 |
/// nodes and edges from the graph.
|
1422 |
1439 |
/// This concept requires \ref AlterableGraphComponent.
|
1423 |
1440 |
template <typename BAS = BaseGraphComponent>
|
1424 |
1441 |
class ErasableGraphComponent : public BAS {
|
1425 |
1442 |
public:
|
1426 |
1443 |
|
1427 |
1444 |
typedef BAS Base;
|
1428 |
1445 |
typedef typename Base::Node Node;
|
1429 |
1446 |
typedef typename Base::Edge Edge;
|
1430 |
1447 |
|
1431 |
1448 |
/// \brief Erase a node from the graph.
|
1432 |
1449 |
///
|
1433 |
1450 |
/// This function erases the given node from the graph and all edges
|
1434 |
1451 |
/// connected to the node.
|
1435 |
1452 |
void erase(const Node&) {}
|
1436 |
1453 |
|
1437 |
1454 |
/// \brief Erase an edge from the digraph.
|
1438 |
1455 |
///
|
1439 |
1456 |
/// This function erases the given edge from the digraph.
|
1440 |
1457 |
void erase(const Edge&) {}
|
1441 |
1458 |
|
1442 |
1459 |
template <typename _Graph>
|
1443 |
1460 |
struct Constraints {
|
1444 |
1461 |
void constraints() {
|
1445 |
1462 |
checkConcept<Base, _Graph>();
|
1446 |
1463 |
const typename _Graph::Node node(INVALID);
|
1447 |
1464 |
graph.erase(node);
|
1448 |
1465 |
const typename _Graph::Edge edge(INVALID);
|
1449 |
1466 |
graph.erase(edge);
|
1450 |
1467 |
}
|
1451 |
1468 |
|
1452 |
1469 |
_Graph& graph;
|
|
1470 |
Constraints() {}
|
1453 |
1471 |
};
|
1454 |
1472 |
};
|
1455 |
1473 |
|
1456 |
1474 |
/// \brief Skeleton class for clearable directed graphs.
|
1457 |
1475 |
///
|
1458 |
1476 |
/// This class describes the interface of clearable directed graphs.
|
1459 |
1477 |
/// It extends \ref BaseDigraphComponent with a function for clearing
|
1460 |
1478 |
/// the digraph.
|
1461 |
1479 |
/// This concept requires \ref AlterableDigraphComponent.
|
1462 |
1480 |
template <typename BAS = BaseDigraphComponent>
|
1463 |
1481 |
class ClearableDigraphComponent : public BAS {
|
1464 |
1482 |
public:
|
1465 |
1483 |
|
1466 |
1484 |
typedef BAS Base;
|
1467 |
1485 |
|
1468 |
1486 |
/// \brief Erase all nodes and arcs from the digraph.
|
1469 |
1487 |
///
|
1470 |
1488 |
/// This function erases all nodes and arcs from the digraph.
|
1471 |
1489 |
void clear() {}
|
1472 |
1490 |
|
1473 |
1491 |
template <typename _Digraph>
|
1474 |
1492 |
struct Constraints {
|
1475 |
1493 |
void constraints() {
|
1476 |
1494 |
checkConcept<Base, _Digraph>();
|
1477 |
1495 |
digraph.clear();
|
1478 |
1496 |
}
|
1479 |
1497 |
|
1480 |
1498 |
_Digraph& digraph;
|
|
1499 |
Constraints() {}
|
1481 |
1500 |
};
|
1482 |
1501 |
};
|
1483 |
1502 |
|
1484 |
1503 |
/// \brief Skeleton class for clearable undirected graphs.
|
1485 |
1504 |
///
|
1486 |
1505 |
/// This class describes the interface of clearable undirected graphs.
|
1487 |
1506 |
/// It extends \ref BaseGraphComponent with a function for clearing
|
1488 |
1507 |
/// the graph.
|
1489 |
1508 |
/// This concept requires \ref AlterableGraphComponent.
|
1490 |
1509 |
template <typename BAS = BaseGraphComponent>
|
1491 |
1510 |
class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {
|
1492 |
1511 |
public:
|
1493 |
1512 |
|
1494 |
1513 |
typedef BAS Base;
|
1495 |
1514 |
|
1496 |
1515 |
/// \brief Erase all nodes and edges from the graph.
|
1497 |
1516 |
///
|
1498 |
1517 |
/// This function erases all nodes and edges from the graph.
|
1499 |
1518 |
void clear() {}
|
1500 |
1519 |
|
1501 |
1520 |
template <typename _Graph>
|
1502 |
1521 |
struct Constraints {
|
1503 |
1522 |
void constraints() {
|
1504 |
1523 |
checkConcept<Base, _Graph>();
|
1505 |
1524 |
graph.clear();
|
1506 |
1525 |
}
|
1507 |
1526 |
|
1508 |
1527 |
_Graph& graph;
|
|
1528 |
Constraints() {}
|
1509 |
1529 |
};
|
1510 |
1530 |
};
|
1511 |
1531 |
|
1512 |
1532 |
}
|
1513 |
1533 |
|
1514 |
1534 |
}
|
1515 |
1535 |
|
1516 |
1536 |
#endif
|