90 /// ordering of the items. |
90 /// ordering of the items. |
91 bool operator<(GraphItem) const { return false; } |
91 bool operator<(GraphItem) const { return false; } |
92 |
92 |
93 template<typename _GraphItem> |
93 template<typename _GraphItem> |
94 struct Constraints { |
94 struct Constraints { |
95 void constraints() { |
95 void constraints() { |
96 _GraphItem i1; |
96 _GraphItem i1; |
97 _GraphItem i2 = i1; |
97 _GraphItem i2 = i1; |
98 _GraphItem i3 = INVALID; |
98 _GraphItem i3 = INVALID; |
99 |
99 |
100 i1 = i2 = i3; |
100 i1 = i2 = i3; |
101 |
101 |
102 bool b; |
102 bool b; |
103 // b = (ia == ib) && (ia != ib) && (ia < ib); |
103 // b = (ia == ib) && (ia != ib) && (ia < ib); |
104 b = (ia == ib) && (ia != ib); |
104 b = (ia == ib) && (ia != ib); |
105 b = (ia == INVALID) && (ib != INVALID); |
105 b = (ia == INVALID) && (ib != INVALID); |
106 b = (ia < ib); |
106 b = (ia < ib); |
107 } |
107 } |
108 |
108 |
109 const _GraphItem &ia; |
109 const _GraphItem &ia; |
110 const _GraphItem &ib; |
110 const _GraphItem &ib; |
111 }; |
111 }; |
112 }; |
112 }; |
113 |
113 |
114 /// \brief An empty base directed graph class. |
114 /// \brief An empty base directed graph class. |
115 /// |
115 /// |
116 /// This class provides the minimal set of features needed for a |
116 /// This class provides the minimal set of features needed for a |
117 /// directed graph structure. All digraph concepts have to be |
117 /// directed graph structure. All digraph concepts have to be |
118 /// conform to this base directed graph. It just provides types |
118 /// conform to this base directed graph. It just provides types |
119 /// for nodes and arcs and functions to get the source and the |
119 /// for nodes and arcs and functions to get the source and the |
120 /// target of the arcs. |
120 /// target of the arcs. |
121 class BaseDigraphComponent { |
121 class BaseDigraphComponent { |
122 public: |
122 public: |
123 |
123 |
124 typedef BaseDigraphComponent Digraph; |
124 typedef BaseDigraphComponent Digraph; |
125 |
125 |
126 /// \brief Node class of the digraph. |
126 /// \brief Node class of the digraph. |
127 /// |
127 /// |
128 /// This class represents the Nodes of the digraph. |
128 /// This class represents the Nodes of the digraph. |
129 /// |
129 /// |
130 typedef GraphItem<'n'> Node; |
130 typedef GraphItem<'n'> Node; |
131 |
131 |
132 /// \brief Arc class of the digraph. |
132 /// \brief Arc class of the digraph. |
133 /// |
133 /// |
134 /// This class represents the Arcs of the digraph. |
134 /// This class represents the Arcs of the digraph. |
135 /// |
135 /// |
136 typedef GraphItem<'e'> Arc; |
136 typedef GraphItem<'e'> Arc; |
137 |
137 |
138 /// \brief Gives back the target node of an arc. |
138 /// \brief Gives back the target node of an arc. |
139 /// |
139 /// |
154 return INVALID; |
154 return INVALID; |
155 } |
155 } |
156 |
156 |
157 template <typename _Digraph> |
157 template <typename _Digraph> |
158 struct Constraints { |
158 struct Constraints { |
159 typedef typename _Digraph::Node Node; |
159 typedef typename _Digraph::Node Node; |
160 typedef typename _Digraph::Arc Arc; |
160 typedef typename _Digraph::Arc Arc; |
161 |
161 |
162 void constraints() { |
162 void constraints() { |
163 checkConcept<GraphItem<'n'>, Node>(); |
163 checkConcept<GraphItem<'n'>, Node>(); |
164 checkConcept<GraphItem<'a'>, Arc>(); |
164 checkConcept<GraphItem<'a'>, Arc>(); |
165 { |
165 { |
166 Node n; |
166 Node n; |
167 Arc e(INVALID); |
167 Arc e(INVALID); |
168 n = digraph.source(e); |
168 n = digraph.source(e); |
169 n = digraph.target(e); |
169 n = digraph.target(e); |
170 n = digraph.oppositeNode(n, e); |
170 n = digraph.oppositeNode(n, e); |
171 } |
171 } |
172 } |
172 } |
173 |
173 |
174 const _Digraph& digraph; |
174 const _Digraph& digraph; |
175 }; |
175 }; |
176 }; |
176 }; |
177 |
177 |
178 /// \brief An empty base undirected graph class. |
178 /// \brief An empty base undirected graph class. |
179 /// |
179 /// |
180 /// This class provides the minimal set of features needed for an |
180 /// This class provides the minimal set of features needed for an |
181 /// undirected graph structure. All undirected graph concepts have |
181 /// undirected graph structure. All undirected graph concepts have |
182 /// to be conform to this base graph. It just provides types for |
182 /// to be conform to this base graph. It just provides types for |
183 /// nodes, arcs and edges and functions to get the |
183 /// nodes, arcs and edges and functions to get the |
184 /// source and the target of the arcs and edges, |
184 /// source and the target of the arcs and edges, |
235 |
235 |
236 /// \brief Returns the directed arc. |
236 /// \brief Returns the directed arc. |
237 /// |
237 /// |
238 /// Returns the directed arc from its direction and the |
238 /// Returns the directed arc from its direction and the |
239 /// represented edge. |
239 /// represented edge. |
240 Arc direct(const Edge&, bool) const { return INVALID;} |
240 Arc direct(const Edge&, bool) const { return INVALID;} |
241 |
241 |
242 /// \brief Returns the directed arc. |
242 /// \brief Returns the directed arc. |
243 /// |
243 /// |
244 /// Returns the directed arc from its source and the |
244 /// Returns the directed arc from its source and the |
245 /// represented edge. |
245 /// represented edge. |
246 Arc direct(const Edge&, const Node&) const { return INVALID;} |
246 Arc direct(const Edge&, const Node&) const { return INVALID;} |
247 |
247 |
248 /// \brief Returns the opposite arc. |
248 /// \brief Returns the opposite arc. |
249 /// |
249 /// |
250 /// Returns the opposite arc. It is the arc representing the |
250 /// Returns the opposite arc. It is the arc representing the |
251 /// same edge and has opposite direction. |
251 /// same edge and has opposite direction. |
258 |
258 |
259 /// \brief Gives back the other ending of an edge. |
259 /// \brief Gives back the other ending of an edge. |
260 /// |
260 /// |
261 /// Gives back the other ending of an edge. |
261 /// Gives back the other ending of an edge. |
262 Node v(const Edge&) const { return INVALID;} |
262 Node v(const Edge&) const { return INVALID;} |
263 |
263 |
264 template <typename _Graph> |
264 template <typename _Graph> |
265 struct Constraints { |
265 struct Constraints { |
266 typedef typename _Graph::Node Node; |
266 typedef typename _Graph::Node Node; |
267 typedef typename _Graph::Arc Arc; |
267 typedef typename _Graph::Arc Arc; |
268 typedef typename _Graph::Edge Edge; |
268 typedef typename _Graph::Edge Edge; |
269 |
269 |
270 void constraints() { |
270 void constraints() { |
271 checkConcept<BaseDigraphComponent, _Graph>(); |
271 checkConcept<BaseDigraphComponent, _Graph>(); |
272 checkConcept<GraphItem<'u'>, Edge>(); |
272 checkConcept<GraphItem<'u'>, Edge>(); |
273 { |
273 { |
274 Node n; |
274 Node n; |
275 Edge ue(INVALID); |
275 Edge ue(INVALID); |
276 Arc e; |
276 Arc e; |
277 n = graph.u(ue); |
277 n = graph.u(ue); |
278 n = graph.v(ue); |
278 n = graph.v(ue); |
279 e = graph.direct(ue, true); |
279 e = graph.direct(ue, true); |
280 e = graph.direct(ue, n); |
280 e = graph.direct(ue, n); |
281 e = graph.oppositeArc(e); |
281 e = graph.oppositeArc(e); |
282 ue = e; |
282 ue = e; |
283 bool d = graph.direction(e); |
283 bool d = graph.direction(e); |
284 ignore_unused_variable_warning(d); |
284 ignore_unused_variable_warning(d); |
285 } |
285 } |
286 } |
286 } |
287 |
287 |
288 const _Graph& graph; |
288 const _Graph& graph; |
289 }; |
289 }; |
290 |
290 |
291 }; |
291 }; |
292 |
292 |
293 /// \brief An empty idable base digraph class. |
293 /// \brief An empty idable base digraph class. |
294 /// |
294 /// |
295 /// This class provides beside the core digraph features |
295 /// This class provides beside the core digraph features |
296 /// core id functions for the digraph structure. |
296 /// core id functions for the digraph structure. |
297 /// The most of the base digraphs should be conform to this concept. |
297 /// The most of the base digraphs should be conform to this concept. |
298 /// The id's are unique and immutable. |
298 /// The id's are unique and immutable. |
299 template <typename _Base = BaseDigraphComponent> |
299 template <typename _Base = BaseDigraphComponent> |
302 |
302 |
303 typedef _Base Base; |
303 typedef _Base Base; |
304 typedef typename Base::Node Node; |
304 typedef typename Base::Node Node; |
305 typedef typename Base::Arc Arc; |
305 typedef typename Base::Arc Arc; |
306 |
306 |
307 /// \brief Gives back an unique integer id for the Node. |
307 /// \brief Gives back an unique integer id for the Node. |
308 /// |
308 /// |
309 /// Gives back an unique integer id for the Node. |
309 /// Gives back an unique integer id for the Node. |
310 /// |
310 /// |
311 int id(const Node&) const { return -1;} |
311 int id(const Node&) const { return -1;} |
312 |
312 |
313 /// \brief Gives back the node by the unique id. |
313 /// \brief Gives back the node by the unique id. |
314 /// |
314 /// |
315 /// Gives back the node by the unique id. |
315 /// Gives back the node by the unique id. |
316 /// If the digraph does not contain node with the given id |
316 /// If the digraph does not contain node with the given id |
317 /// then the result of the function is undetermined. |
317 /// then the result of the function is undetermined. |
318 Node nodeFromId(int) const { return INVALID;} |
318 Node nodeFromId(int) const { return INVALID;} |
319 |
319 |
320 /// \brief Gives back an unique integer id for the Arc. |
320 /// \brief Gives back an unique integer id for the Arc. |
321 /// |
321 /// |
322 /// Gives back an unique integer id for the Arc. |
322 /// Gives back an unique integer id for the Arc. |
323 /// |
323 /// |
324 int id(const Arc&) const { return -1;} |
324 int id(const Arc&) const { return -1;} |
325 |
325 |
326 /// \brief Gives back the arc by the unique id. |
326 /// \brief Gives back the arc by the unique id. |
327 /// |
327 /// |
328 /// Gives back the arc by the unique id. |
328 /// Gives back the arc by the unique id. |
329 /// If the digraph does not contain arc with the given id |
329 /// If the digraph does not contain arc with the given id |
330 /// then the result of the function is undetermined. |
330 /// then the result of the function is undetermined. |
331 Arc arcFromId(int) const { return INVALID;} |
331 Arc arcFromId(int) const { return INVALID;} |
332 |
332 |
333 /// \brief Gives back an integer greater or equal to the maximum |
333 /// \brief Gives back an integer greater or equal to the maximum |
334 /// Node id. |
334 /// Node id. |
335 /// |
335 /// |
345 int maxArcId() const { return -1;} |
345 int maxArcId() const { return -1;} |
346 |
346 |
347 template <typename _Digraph> |
347 template <typename _Digraph> |
348 struct Constraints { |
348 struct Constraints { |
349 |
349 |
350 void constraints() { |
350 void constraints() { |
351 checkConcept<Base, _Digraph >(); |
351 checkConcept<Base, _Digraph >(); |
352 typename _Digraph::Node node; |
352 typename _Digraph::Node node; |
353 int nid = digraph.id(node); |
353 int nid = digraph.id(node); |
354 nid = digraph.id(node); |
354 nid = digraph.id(node); |
355 node = digraph.nodeFromId(nid); |
355 node = digraph.nodeFromId(nid); |
356 typename _Digraph::Arc arc; |
356 typename _Digraph::Arc arc; |
357 int eid = digraph.id(arc); |
357 int eid = digraph.id(arc); |
358 eid = digraph.id(arc); |
358 eid = digraph.id(arc); |
359 arc = digraph.arcFromId(eid); |
359 arc = digraph.arcFromId(eid); |
360 |
360 |
361 nid = digraph.maxNodeId(); |
361 nid = digraph.maxNodeId(); |
362 ignore_unused_variable_warning(nid); |
362 ignore_unused_variable_warning(nid); |
363 eid = digraph.maxArcId(); |
363 eid = digraph.maxArcId(); |
364 ignore_unused_variable_warning(eid); |
364 ignore_unused_variable_warning(eid); |
365 } |
365 } |
366 |
366 |
367 const _Digraph& digraph; |
367 const _Digraph& digraph; |
368 }; |
368 }; |
369 }; |
369 }; |
370 |
370 |
371 /// \brief An empty idable base undirected graph class. |
371 /// \brief An empty idable base undirected graph class. |
372 /// |
372 /// |
373 /// This class provides beside the core undirected graph features |
373 /// This class provides beside the core undirected graph features |
374 /// core id functions for the undirected graph structure. The |
374 /// core id functions for the undirected graph structure. The |
375 /// most of the base undirected graphs should be conform to this |
375 /// most of the base undirected graphs should be conform to this |
376 /// concept. The id's are unique and immutable. |
376 /// concept. The id's are unique and immutable. |
377 template <typename _Base = BaseGraphComponent> |
377 template <typename _Base = BaseGraphComponent> |
404 int maxEdgeId() const { return -1;} |
404 int maxEdgeId() const { return -1;} |
405 |
405 |
406 template <typename _Graph> |
406 template <typename _Graph> |
407 struct Constraints { |
407 struct Constraints { |
408 |
408 |
409 void constraints() { |
409 void constraints() { |
410 checkConcept<Base, _Graph >(); |
410 checkConcept<Base, _Graph >(); |
411 checkConcept<IDableDigraphComponent<Base>, _Graph >(); |
411 checkConcept<IDableDigraphComponent<Base>, _Graph >(); |
412 typename _Graph::Edge edge; |
412 typename _Graph::Edge edge; |
413 int ueid = graph.id(edge); |
413 int ueid = graph.id(edge); |
414 ueid = graph.id(edge); |
414 ueid = graph.id(edge); |
415 edge = graph.edgeFromId(ueid); |
415 edge = graph.edgeFromId(ueid); |
416 ueid = graph.maxEdgeId(); |
416 ueid = graph.maxEdgeId(); |
417 ignore_unused_variable_warning(ueid); |
417 ignore_unused_variable_warning(ueid); |
418 } |
418 } |
419 |
419 |
420 const _Graph& graph; |
420 const _Graph& graph; |
421 }; |
421 }; |
422 }; |
422 }; |
423 |
423 |
424 /// \brief Skeleton class for graph NodeIt and ArcIt |
424 /// \brief Skeleton class for graph NodeIt and ArcIt |
425 /// |
425 /// |
448 /// This constructor initializes the item to be invalid. |
448 /// This constructor initializes the item to be invalid. |
449 /// \sa Invalid for more details. |
449 /// \sa Invalid for more details. |
450 GraphItemIt(Invalid) {} |
450 GraphItemIt(Invalid) {} |
451 /// \brief Assign operator for items. |
451 /// \brief Assign operator for items. |
452 /// |
452 /// |
453 /// The items are assignable. |
453 /// The items are assignable. |
454 /// |
454 /// |
455 GraphItemIt& operator=(const GraphItemIt&) { return *this; } |
455 GraphItemIt& operator=(const GraphItemIt&) { return *this; } |
456 /// \brief Next item. |
456 /// \brief Next item. |
457 /// |
457 /// |
458 /// Assign the iterator to the next item. |
458 /// Assign the iterator to the next item. |
459 /// |
459 /// |
460 GraphItemIt& operator++() { return *this; } |
460 GraphItemIt& operator++() { return *this; } |
461 /// \brief Equality operator |
461 /// \brief Equality operator |
462 /// |
462 /// |
463 /// Two iterators are equal if and only if they point to the |
463 /// Two iterators are equal if and only if they point to the |
464 /// same object or both are invalid. |
464 /// same object or both are invalid. |
465 bool operator==(const GraphItemIt&) const { return true;} |
465 bool operator==(const GraphItemIt&) const { return true;} |
466 /// \brief Inequality operator |
466 /// \brief Inequality operator |
467 /// |
467 /// |
468 /// \sa operator==(Node n) |
468 /// \sa operator==(Node n) |
469 /// |
469 /// |
470 bool operator!=(const GraphItemIt&) const { return true;} |
470 bool operator!=(const GraphItemIt&) const { return true;} |
471 |
471 |
472 template<typename _GraphItemIt> |
472 template<typename _GraphItemIt> |
473 struct Constraints { |
473 struct Constraints { |
474 void constraints() { |
474 void constraints() { |
475 _GraphItemIt it1(g); |
475 _GraphItemIt it1(g); |
476 _GraphItemIt it2; |
476 _GraphItemIt it2; |
477 |
477 |
478 it2 = ++it1; |
478 it2 = ++it1; |
479 ++it2 = it1; |
479 ++it2 = it1; |
480 ++(++it1); |
480 ++(++it1); |
481 |
481 |
482 _Item bi = it1; |
482 _Item bi = it1; |
483 bi = it2; |
483 bi = it2; |
484 } |
484 } |
485 _Graph& g; |
485 _Graph& g; |
486 }; |
486 }; |
487 }; |
487 }; |
488 |
488 |
489 /// \brief Skeleton class for graph InArcIt and OutArcIt |
489 /// \brief Skeleton class for graph InArcIt and OutArcIt |
490 /// |
490 /// |
491 /// \note Because InArcIt and OutArcIt may not inherit from the same |
491 /// \note Because InArcIt and OutArcIt may not inherit from the same |
492 /// base class, the _selector is a additional template parameter. For |
492 /// base class, the _selector is a additional template parameter. For |
493 /// InArcIt you should instantiate it with character 'i' and for |
493 /// InArcIt you should instantiate it with character 'i' and for |
494 /// OutArcIt with 'o'. |
494 /// OutArcIt with 'o'. |
495 template <typename _Graph, |
495 template <typename _Graph, |
496 typename _Item = typename _Graph::Arc, |
496 typename _Item = typename _Graph::Arc, |
497 typename _Base = typename _Graph::Node, |
497 typename _Base = typename _Graph::Node, |
498 char _selector = '0'> |
498 char _selector = '0'> |
499 class GraphIncIt : public _Item { |
499 class GraphIncIt : public _Item { |
500 public: |
500 public: |
501 /// \brief Default constructor. |
501 /// \brief Default constructor. |
502 /// |
502 /// |
503 /// @warning The default constructor sets the iterator |
503 /// @warning The default constructor sets the iterator |
506 /// \brief Copy constructor. |
506 /// \brief Copy constructor. |
507 /// |
507 /// |
508 /// Copy constructor. |
508 /// Copy constructor. |
509 /// |
509 /// |
510 GraphIncIt(GraphIncIt const& gi) : _Item(gi) {} |
510 GraphIncIt(GraphIncIt const& gi) : _Item(gi) {} |
511 /// \brief Sets the iterator to the first arc incoming into or outgoing |
511 /// \brief Sets the iterator to the first arc incoming into or outgoing |
512 /// from the node. |
512 /// from the node. |
513 /// |
513 /// |
514 /// Sets the iterator to the first arc incoming into or outgoing |
514 /// Sets the iterator to the first arc incoming into or outgoing |
515 /// from the node. |
515 /// from the node. |
516 /// |
516 /// |
517 explicit GraphIncIt(const _Graph&, const _Base&) {} |
517 explicit GraphIncIt(const _Graph&, const _Base&) {} |
518 /// \brief Invalid constructor \& conversion. |
518 /// \brief Invalid constructor \& conversion. |
519 /// |
519 /// |
520 /// This constructor initializes the item to be invalid. |
520 /// This constructor initializes the item to be invalid. |
521 /// \sa Invalid for more details. |
521 /// \sa Invalid for more details. |
522 GraphIncIt(Invalid) {} |
522 GraphIncIt(Invalid) {} |
523 /// \brief Assign operator for iterators. |
523 /// \brief Assign operator for iterators. |
524 /// |
524 /// |
525 /// The iterators are assignable. |
525 /// The iterators are assignable. |
526 /// |
526 /// |
527 GraphIncIt& operator=(GraphIncIt const&) { return *this; } |
527 GraphIncIt& operator=(GraphIncIt const&) { return *this; } |
528 /// \brief Next item. |
528 /// \brief Next item. |
529 /// |
529 /// |
530 /// Assign the iterator to the next item. |
530 /// Assign the iterator to the next item. |
531 /// |
531 /// |
532 GraphIncIt& operator++() { return *this; } |
532 GraphIncIt& operator++() { return *this; } |
573 /// This concept is part of the Digraph concept. |
573 /// This concept is part of the Digraph concept. |
574 template <typename _Base = BaseDigraphComponent> |
574 template <typename _Base = BaseDigraphComponent> |
575 class IterableDigraphComponent : public _Base { |
575 class IterableDigraphComponent : public _Base { |
576 |
576 |
577 public: |
577 public: |
578 |
578 |
579 typedef _Base Base; |
579 typedef _Base Base; |
580 typedef typename Base::Node Node; |
580 typedef typename Base::Node Node; |
581 typedef typename Base::Arc Arc; |
581 typedef typename Base::Arc Arc; |
582 |
582 |
583 typedef IterableDigraphComponent Digraph; |
583 typedef IterableDigraphComponent Digraph; |
584 |
584 |
585 /// \name Base iteration |
585 /// \name Base iteration |
586 /// |
586 /// |
587 /// This interface provides functions for iteration on digraph items |
587 /// This interface provides functions for iteration on digraph items |
588 /// |
588 /// |
589 /// @{ |
589 /// @{ |
590 |
590 |
591 /// \brief Gives back the first node in the iterating order. |
591 /// \brief Gives back the first node in the iterating order. |
592 /// |
592 /// |
593 /// Gives back the first node in the iterating order. |
593 /// Gives back the first node in the iterating order. |
594 /// |
594 /// |
595 void first(Node&) const {} |
595 void first(Node&) const {} |
596 |
596 |
597 /// \brief Gives back the next node in the iterating order. |
597 /// \brief Gives back the next node in the iterating order. |
598 /// |
598 /// |
599 /// Gives back the next node in the iterating order. |
599 /// Gives back the next node in the iterating order. |
600 /// |
600 /// |
601 void next(Node&) const {} |
601 void next(Node&) const {} |
602 |
602 |
603 /// \brief Gives back the first arc in the iterating order. |
603 /// \brief Gives back the first arc in the iterating order. |
604 /// |
604 /// |
605 /// Gives back the first arc in the iterating order. |
605 /// Gives back the first arc in the iterating order. |
606 /// |
606 /// |
607 void first(Arc&) const {} |
607 void first(Arc&) const {} |
608 |
608 |
609 /// \brief Gives back the next arc in the iterating order. |
609 /// \brief Gives back the next arc in the iterating order. |
610 /// |
610 /// |
611 /// Gives back the next arc in the iterating order. |
611 /// Gives back the next arc in the iterating order. |
612 /// |
612 /// |
613 void next(Arc&) const {} |
613 void next(Arc&) const {} |
614 |
614 |
615 |
615 |
616 /// \brief Gives back the first of the arcs point to the given |
616 /// \brief Gives back the first of the arcs point to the given |
617 /// node. |
617 /// node. |
618 /// |
618 /// |
619 /// Gives back the first of the arcs point to the given node. |
619 /// Gives back the first of the arcs point to the given node. |
620 /// |
620 /// |
621 void firstIn(Arc&, const Node&) const {} |
621 void firstIn(Arc&, const Node&) const {} |
622 |
622 |
623 /// \brief Gives back the next of the arcs points to the given |
623 /// \brief Gives back the next of the arcs points to the given |
624 /// node. |
624 /// node. |
625 /// |
625 /// |
627 /// |
627 /// |
628 void nextIn(Arc&) const {} |
628 void nextIn(Arc&) const {} |
629 |
629 |
630 /// \brief Gives back the first of the arcs start from the |
630 /// \brief Gives back the first of the arcs start from the |
631 /// given node. |
631 /// given node. |
632 /// |
632 /// |
633 /// Gives back the first of the arcs start from the given node. |
633 /// Gives back the first of the arcs start from the given node. |
634 /// |
634 /// |
635 void firstOut(Arc&, const Node&) const {} |
635 void firstOut(Arc&, const Node&) const {} |
636 |
636 |
637 /// \brief Gives back the next of the arcs start from the given |
637 /// \brief Gives back the next of the arcs start from the given |
638 /// node. |
638 /// node. |
639 /// |
639 /// |
640 /// Gives back the next of the arcs start from the given node. |
640 /// Gives back the next of the arcs start from the given node. |
641 /// |
641 /// |
642 void nextOut(Arc&) const {} |
642 void nextOut(Arc&) const {} |
643 |
643 |
644 /// @} |
644 /// @} |
645 |
645 |
646 /// \name Class based iteration |
646 /// \name Class based iteration |
647 /// |
647 /// |
648 /// This interface provides functions for iteration on digraph items |
648 /// This interface provides functions for iteration on digraph items |
649 /// |
649 /// |
650 /// @{ |
650 /// @{ |
651 |
651 |
652 /// \brief This iterator goes through each node. |
652 /// \brief This iterator goes through each node. |
721 } |
721 } |
722 { |
722 { |
723 digraph.firstOut(arc, node); |
723 digraph.firstOut(arc, node); |
724 digraph.nextOut(arc); |
724 digraph.nextOut(arc); |
725 } |
725 } |
726 } |
726 } |
727 |
727 |
728 { |
728 { |
729 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>, |
729 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>, |
730 typename _Digraph::ArcIt >(); |
730 typename _Digraph::ArcIt >(); |
731 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>, |
731 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>, |
732 typename _Digraph::NodeIt >(); |
732 typename _Digraph::NodeIt >(); |
733 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc, |
733 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc, |
734 typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>(); |
734 typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>(); |
735 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc, |
735 checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc, |
736 typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>(); |
736 typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>(); |
737 |
737 |
738 typename _Digraph::Node n; |
738 typename _Digraph::Node n; |
739 typename _Digraph::InArcIt ieit(INVALID); |
739 typename _Digraph::InArcIt ieit(INVALID); |
740 typename _Digraph::OutArcIt oeit(INVALID); |
740 typename _Digraph::OutArcIt oeit(INVALID); |
763 typedef _Base Base; |
763 typedef _Base Base; |
764 typedef typename Base::Node Node; |
764 typedef typename Base::Node Node; |
765 typedef typename Base::Arc Arc; |
765 typedef typename Base::Arc Arc; |
766 typedef typename Base::Edge Edge; |
766 typedef typename Base::Edge Edge; |
767 |
767 |
768 |
768 |
769 typedef IterableGraphComponent Graph; |
769 typedef IterableGraphComponent Graph; |
770 |
770 |
771 /// \name Base iteration |
771 /// \name Base iteration |
772 /// |
772 /// |
773 /// This interface provides functions for iteration on graph items |
773 /// This interface provides functions for iteration on graph items |
774 /// @{ |
774 /// @{ |
775 |
775 |
776 using IterableDigraphComponent<_Base>::first; |
776 using IterableDigraphComponent<_Base>::first; |
777 using IterableDigraphComponent<_Base>::next; |
777 using IterableDigraphComponent<_Base>::next; |
778 |
778 |
779 /// \brief Gives back the first edge in the iterating |
779 /// \brief Gives back the first edge in the iterating |
780 /// order. |
780 /// order. |
781 /// |
781 /// |
782 /// Gives back the first edge in the iterating order. |
782 /// Gives back the first edge in the iterating order. |
783 /// |
783 /// |
784 void first(Edge&) const {} |
784 void first(Edge&) const {} |
785 |
785 |
786 /// \brief Gives back the next edge in the iterating |
786 /// \brief Gives back the next edge in the iterating |
787 /// order. |
787 /// order. |
788 /// |
788 /// |
789 /// Gives back the next edge in the iterating order. |
789 /// Gives back the next edge in the iterating order. |
790 /// |
790 /// |
791 void next(Edge&) const {} |
791 void next(Edge&) const {} |
792 |
792 |
793 |
793 |
794 /// \brief Gives back the first of the edges from the |
794 /// \brief Gives back the first of the edges from the |
795 /// given node. |
795 /// given node. |
856 } |
856 } |
857 { |
857 { |
858 graph.firstInc(edge, dir, node); |
858 graph.firstInc(edge, dir, node); |
859 graph.nextInc(edge, dir); |
859 graph.nextInc(edge, dir); |
860 } |
860 } |
861 |
861 |
862 } |
862 } |
863 |
863 |
864 { |
864 { |
865 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>, |
865 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>, |
866 typename _Graph::EdgeIt >(); |
866 typename _Graph::EdgeIt >(); |
867 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, |
867 checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, |
868 typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>(); |
868 typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>(); |
869 |
869 |
870 typename _Graph::Node n; |
870 typename _Graph::Node n; |
871 typename _Graph::IncEdgeIt ueit(INVALID); |
871 typename _Graph::IncEdgeIt ueit(INVALID); |
872 n = graph.baseNode(ueit); |
872 n = graph.baseNode(ueit); |
873 n = graph.runningNode(ueit); |
873 n = graph.runningNode(ueit); |
874 } |
874 } |
875 } |
875 } |
876 |
876 |
877 const _Graph& graph; |
877 const _Graph& graph; |
878 |
878 |
879 }; |
879 }; |
880 }; |
880 }; |
881 |
881 |
882 /// \brief An empty alteration notifier digraph class. |
882 /// \brief An empty alteration notifier digraph class. |
883 /// |
883 /// |
884 /// This class provides beside the core digraph features alteration |
884 /// This class provides beside the core digraph features alteration |
885 /// notifier interface for the digraph structure. This implements |
885 /// notifier interface for the digraph structure. This implements |
886 /// an observer-notifier pattern for each digraph item. More |
886 /// an observer-notifier pattern for each digraph item. More |
887 /// obsevers can be registered into the notifier and whenever an |
887 /// obsevers can be registered into the notifier and whenever an |
888 /// alteration occured in the digraph all the observers will |
888 /// alteration occured in the digraph all the observers will |
895 typedef typename Base::Node Node; |
895 typedef typename Base::Node Node; |
896 typedef typename Base::Arc Arc; |
896 typedef typename Base::Arc Arc; |
897 |
897 |
898 |
898 |
899 /// The node observer registry. |
899 /// The node observer registry. |
900 typedef AlterationNotifier<AlterableDigraphComponent, Node> |
900 typedef AlterationNotifier<AlterableDigraphComponent, Node> |
901 NodeNotifier; |
901 NodeNotifier; |
902 /// The arc observer registry. |
902 /// The arc observer registry. |
903 typedef AlterationNotifier<AlterableDigraphComponent, Arc> |
903 typedef AlterationNotifier<AlterableDigraphComponent, Arc> |
904 ArcNotifier; |
904 ArcNotifier; |
905 |
905 |
906 /// \brief Gives back the node alteration notifier. |
906 /// \brief Gives back the node alteration notifier. |
907 /// |
907 /// |
908 /// Gives back the node alteration notifier. |
908 /// Gives back the node alteration notifier. |
909 NodeNotifier& notifier(Node) const { |
909 NodeNotifier& notifier(Node) const { |
910 return NodeNotifier(); |
910 return NodeNotifier(); |
911 } |
911 } |
912 |
912 |
913 /// \brief Gives back the arc alteration notifier. |
913 /// \brief Gives back the arc alteration notifier. |
914 /// |
914 /// |
915 /// Gives back the arc alteration notifier. |
915 /// Gives back the arc alteration notifier. |
916 ArcNotifier& notifier(Arc) const { |
916 ArcNotifier& notifier(Arc) const { |
917 return ArcNotifier(); |
917 return ArcNotifier(); |
918 } |
918 } |
919 |
919 |
920 template <typename _Digraph> |
920 template <typename _Digraph> |
921 struct Constraints { |
921 struct Constraints { |
922 void constraints() { |
922 void constraints() { |
923 checkConcept<Base, _Digraph>(); |
923 checkConcept<Base, _Digraph>(); |
924 typename _Digraph::NodeNotifier& nn |
924 typename _Digraph::NodeNotifier& nn |
925 = digraph.notifier(typename _Digraph::Node()); |
925 = digraph.notifier(typename _Digraph::Node()); |
926 |
926 |
927 typename _Digraph::ArcNotifier& en |
927 typename _Digraph::ArcNotifier& en |
928 = digraph.notifier(typename _Digraph::Arc()); |
928 = digraph.notifier(typename _Digraph::Arc()); |
929 |
929 |
930 ignore_unused_variable_warning(nn); |
930 ignore_unused_variable_warning(nn); |
931 ignore_unused_variable_warning(en); |
931 ignore_unused_variable_warning(en); |
932 } |
932 } |
933 |
933 |
934 const _Digraph& digraph; |
934 const _Digraph& digraph; |
935 |
935 |
936 }; |
936 }; |
937 |
937 |
938 }; |
938 }; |
939 |
939 |
940 /// \brief An empty alteration notifier undirected graph class. |
940 /// \brief An empty alteration notifier undirected graph class. |
941 /// |
941 /// |
942 /// This class provides beside the core graph features alteration |
942 /// This class provides beside the core graph features alteration |
943 /// notifier interface for the graph structure. This implements |
943 /// notifier interface for the graph structure. This implements |
944 /// an observer-notifier pattern for each graph item. More |
944 /// an observer-notifier pattern for each graph item. More |
945 /// obsevers can be registered into the notifier and whenever an |
945 /// obsevers can be registered into the notifier and whenever an |
946 /// alteration occured in the graph all the observers will |
946 /// alteration occured in the graph all the observers will |
952 typedef _Base Base; |
952 typedef _Base Base; |
953 typedef typename Base::Edge Edge; |
953 typedef typename Base::Edge Edge; |
954 |
954 |
955 |
955 |
956 /// The arc observer registry. |
956 /// The arc observer registry. |
957 typedef AlterationNotifier<AlterableGraphComponent, Edge> |
957 typedef AlterationNotifier<AlterableGraphComponent, Edge> |
958 EdgeNotifier; |
958 EdgeNotifier; |
959 |
959 |
960 /// \brief Gives back the arc alteration notifier. |
960 /// \brief Gives back the arc alteration notifier. |
961 /// |
961 /// |
962 /// Gives back the arc alteration notifier. |
962 /// Gives back the arc alteration notifier. |
963 EdgeNotifier& notifier(Edge) const { |
963 EdgeNotifier& notifier(Edge) const { |
964 return EdgeNotifier(); |
964 return EdgeNotifier(); |
965 } |
965 } |
966 |
966 |
967 template <typename _Graph> |
967 template <typename _Graph> |
968 struct Constraints { |
968 struct Constraints { |
969 void constraints() { |
969 void constraints() { |
970 checkConcept<AlterableGraphComponent<Base>, _Graph>(); |
970 checkConcept<AlterableGraphComponent<Base>, _Graph>(); |
971 typename _Graph::EdgeNotifier& uen |
971 typename _Graph::EdgeNotifier& uen |
972 = graph.notifier(typename _Graph::Edge()); |
972 = graph.notifier(typename _Graph::Edge()); |
973 ignore_unused_variable_warning(uen); |
973 ignore_unused_variable_warning(uen); |
974 } |
974 } |
975 |
975 |
976 const _Graph& graph; |
976 const _Graph& graph; |
977 |
977 |
978 }; |
978 }; |
979 |
979 |
980 }; |
980 }; |
981 |
981 |
982 /// \brief Class describing the concept of graph maps |
982 /// \brief Class describing the concept of graph maps |
983 /// |
983 /// |
984 /// This class describes the common interface of the graph maps |
984 /// This class describes the common interface of the graph maps |
985 /// (NodeMap, ArcMap), that is \ref maps-page "maps" which can be used to |
985 /// (NodeMap, ArcMap), that is \ref maps-page "maps" which can be used to |
986 /// associate data to graph descriptors (nodes or arcs). |
986 /// associate data to graph descriptors (nodes or arcs). |
987 template <typename _Graph, typename _Item, typename _Value> |
987 template <typename _Graph, typename _Item, typename _Value> |
988 class GraphMap : public ReadWriteMap<_Item, _Value> { |
988 class GraphMap : public ReadWriteMap<_Item, _Value> { |
1007 GraphMap(const Graph&, const Value&) {} |
1007 GraphMap(const Graph&, const Value&) {} |
1008 /// \brief Copy constructor. |
1008 /// \brief Copy constructor. |
1009 /// |
1009 /// |
1010 /// Copy Constructor. |
1010 /// Copy Constructor. |
1011 GraphMap(const GraphMap&) : Parent() {} |
1011 GraphMap(const GraphMap&) : Parent() {} |
1012 |
1012 |
1013 /// \brief Assign operator. |
1013 /// \brief Assign operator. |
1014 /// |
1014 /// |
1015 /// Assign operator. It does not mofify the underlying graph, |
1015 /// Assign operator. It does not mofify the underlying graph, |
1016 /// it just iterates on the current item set and set the map |
1016 /// it just iterates on the current item set and set the map |
1017 /// with the value returned by the assigned map. |
1017 /// with the value returned by the assigned map. |
1018 template <typename CMap> |
1018 template <typename CMap> |
1019 GraphMap& operator=(const CMap&) { |
1019 GraphMap& operator=(const CMap&) { |
1020 checkConcept<ReadMap<Key, Value>, CMap>(); |
1020 checkConcept<ReadMap<Key, Value>, CMap>(); |
1021 return *this; |
1021 return *this; |
1022 } |
1022 } |
1023 |
1023 |
1024 template<typename _Map> |
1024 template<typename _Map> |
1025 struct Constraints { |
1025 struct Constraints { |
1026 void constraints() { |
1026 void constraints() { |
1027 checkConcept<ReadWriteMap<Key, Value>, _Map >(); |
1027 checkConcept<ReadWriteMap<Key, Value>, _Map >(); |
1028 // Construction with a graph parameter |
1028 // Construction with a graph parameter |
1029 _Map a(g); |
1029 _Map a(g); |
1030 // Constructor with a graph and a default value parameter |
1030 // Constructor with a graph and a default value parameter |
1031 _Map a2(g,t); |
1031 _Map a2(g,t); |
1032 // Copy constructor. |
1032 // Copy constructor. |
1033 _Map b(c); |
1033 _Map b(c); |
1034 |
1034 |
1035 ReadMap<Key, Value> cmap; |
1035 ReadMap<Key, Value> cmap; |
1036 b = cmap; |
1036 b = cmap; |
1037 |
1037 |
1038 ignore_unused_variable_warning(a2); |
1038 ignore_unused_variable_warning(a2); |
1039 ignore_unused_variable_warning(b); |
1039 ignore_unused_variable_warning(b); |
1040 } |
1040 } |
1041 |
1041 |
1042 const _Map &c; |
1042 const _Map &c; |
1043 const Graph &g; |
1043 const Graph &g; |
1044 const typename GraphMap::Value &t; |
1044 const typename GraphMap::Value &t; |
1045 }; |
1045 }; |
1046 |
1046 |
1047 }; |
1047 }; |
1048 |
1048 |
1049 /// \brief An empty mappable digraph class. |
1049 /// \brief An empty mappable digraph class. |
1068 template <typename _Value> |
1068 template <typename _Value> |
1069 class NodeMap : public GraphMap<Digraph, Node, _Value> { |
1069 class NodeMap : public GraphMap<Digraph, Node, _Value> { |
1070 public: |
1070 public: |
1071 typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent; |
1071 typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent; |
1072 |
1072 |
1073 /// \brief Construct a new map. |
1073 /// \brief Construct a new map. |
1074 /// |
1074 /// |
1075 /// Construct a new map for the digraph. |
1075 /// Construct a new map for the digraph. |
1076 explicit NodeMap(const MappableDigraphComponent& digraph) |
1076 explicit NodeMap(const MappableDigraphComponent& digraph) |
1077 : Parent(digraph) {} |
1077 : Parent(digraph) {} |
1078 |
1078 |
1079 /// \brief Construct a new map with default value. |
1079 /// \brief Construct a new map with default value. |
1080 /// |
1080 /// |
1081 /// Construct a new map for the digraph and initalise the values. |
1081 /// Construct a new map for the digraph and initalise the values. |
1082 NodeMap(const MappableDigraphComponent& digraph, const _Value& value) |
1082 NodeMap(const MappableDigraphComponent& digraph, const _Value& value) |
1083 : Parent(digraph, value) {} |
1083 : Parent(digraph, value) {} |
1084 |
1084 |
1085 /// \brief Copy constructor. |
1085 /// \brief Copy constructor. |
1086 /// |
1086 /// |
1087 /// Copy Constructor. |
1087 /// Copy Constructor. |
1088 NodeMap(const NodeMap& nm) : Parent(nm) {} |
1088 NodeMap(const NodeMap& nm) : Parent(nm) {} |
1089 |
1089 |
1090 /// \brief Assign operator. |
1090 /// \brief Assign operator. |
1091 /// |
1091 /// |
1092 /// Assign operator. |
1092 /// Assign operator. |
1093 template <typename CMap> |
1093 template <typename CMap> |
1094 NodeMap& operator=(const CMap&) { |
1094 NodeMap& operator=(const CMap&) { |
1095 checkConcept<ReadMap<Node, _Value>, CMap>(); |
1095 checkConcept<ReadMap<Node, _Value>, CMap>(); |
1096 return *this; |
1096 return *this; |
1097 } |
1097 } |
1098 |
1098 |
1099 }; |
1099 }; |
1105 template <typename _Value> |
1105 template <typename _Value> |
1106 class ArcMap : public GraphMap<Digraph, Arc, _Value> { |
1106 class ArcMap : public GraphMap<Digraph, Arc, _Value> { |
1107 public: |
1107 public: |
1108 typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent; |
1108 typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent; |
1109 |
1109 |
1110 /// \brief Construct a new map. |
1110 /// \brief Construct a new map. |
1111 /// |
1111 /// |
1112 /// Construct a new map for the digraph. |
1112 /// Construct a new map for the digraph. |
1113 explicit ArcMap(const MappableDigraphComponent& digraph) |
1113 explicit ArcMap(const MappableDigraphComponent& digraph) |
1114 : Parent(digraph) {} |
1114 : Parent(digraph) {} |
1115 |
1115 |
1116 /// \brief Construct a new map with default value. |
1116 /// \brief Construct a new map with default value. |
1117 /// |
1117 /// |
1118 /// Construct a new map for the digraph and initalise the values. |
1118 /// Construct a new map for the digraph and initalise the values. |
1119 ArcMap(const MappableDigraphComponent& digraph, const _Value& value) |
1119 ArcMap(const MappableDigraphComponent& digraph, const _Value& value) |
1120 : Parent(digraph, value) {} |
1120 : Parent(digraph, value) {} |
1121 |
1121 |
1122 /// \brief Copy constructor. |
1122 /// \brief Copy constructor. |
1123 /// |
1123 /// |
1124 /// Copy Constructor. |
1124 /// Copy Constructor. |
1125 ArcMap(const ArcMap& nm) : Parent(nm) {} |
1125 ArcMap(const ArcMap& nm) : Parent(nm) {} |
1126 |
1126 |
1127 /// \brief Assign operator. |
1127 /// \brief Assign operator. |
1128 /// |
1128 /// |
1129 /// Assign operator. |
1129 /// Assign operator. |
1130 template <typename CMap> |
1130 template <typename CMap> |
1131 ArcMap& operator=(const CMap&) { |
1131 ArcMap& operator=(const CMap&) { |
1132 checkConcept<ReadMap<Arc, _Value>, CMap>(); |
1132 checkConcept<ReadMap<Arc, _Value>, CMap>(); |
1133 return *this; |
1133 return *this; |
1134 } |
1134 } |
1135 |
1135 |
1136 }; |
1136 }; |
1137 |
1137 |
1138 |
1138 |
1139 template <typename _Digraph> |
1139 template <typename _Digraph> |
1140 struct Constraints { |
1140 struct Constraints { |
1141 |
1141 |
1142 struct Dummy { |
1142 struct Dummy { |
1143 int value; |
1143 int value; |
1144 Dummy() : value(0) {} |
1144 Dummy() : value(0) {} |
1145 Dummy(int _v) : value(_v) {} |
1145 Dummy(int _v) : value(_v) {} |
1146 }; |
1146 }; |
1147 |
1147 |
1148 void constraints() { |
1148 void constraints() { |
1149 checkConcept<Base, _Digraph>(); |
1149 checkConcept<Base, _Digraph>(); |
1150 { // int map test |
1150 { // int map test |
1151 typedef typename _Digraph::template NodeMap<int> IntNodeMap; |
1151 typedef typename _Digraph::template NodeMap<int> IntNodeMap; |
1152 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>, |
1152 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>, |
1153 IntNodeMap >(); |
1153 IntNodeMap >(); |
1154 } { // bool map test |
1154 } { // bool map test |
1155 typedef typename _Digraph::template NodeMap<bool> BoolNodeMap; |
1155 typedef typename _Digraph::template NodeMap<bool> BoolNodeMap; |
1156 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>, |
1156 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>, |
1157 BoolNodeMap >(); |
1157 BoolNodeMap >(); |
1158 } { // Dummy map test |
1158 } { // Dummy map test |
1159 typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap; |
1159 typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap; |
1160 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>, |
1160 checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>, |
1161 DummyNodeMap >(); |
1161 DummyNodeMap >(); |
1162 } |
1162 } |
1163 |
1163 |
1164 { // int map test |
1164 { // int map test |
1165 typedef typename _Digraph::template ArcMap<int> IntArcMap; |
1165 typedef typename _Digraph::template ArcMap<int> IntArcMap; |
1166 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>, |
1166 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>, |
1167 IntArcMap >(); |
1167 IntArcMap >(); |
1168 } { // bool map test |
1168 } { // bool map test |
1169 typedef typename _Digraph::template ArcMap<bool> BoolArcMap; |
1169 typedef typename _Digraph::template ArcMap<bool> BoolArcMap; |
1170 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>, |
1170 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>, |
1171 BoolArcMap >(); |
1171 BoolArcMap >(); |
1172 } { // Dummy map test |
1172 } { // Dummy map test |
1173 typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap; |
1173 typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap; |
1174 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>, |
1174 checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>, |
1175 DummyArcMap >(); |
1175 DummyArcMap >(); |
1176 } |
1176 } |
1177 } |
1177 } |
1178 |
1178 |
1179 _Digraph& digraph; |
1179 _Digraph& digraph; |
1180 }; |
1180 }; |
1181 }; |
1181 }; |
1182 |
1182 |
1183 /// \brief An empty mappable base bipartite graph class. |
1183 /// \brief An empty mappable base bipartite graph class. |
1184 /// |
1184 /// |
1197 /// \brief ReadWrite map of the edges. |
1197 /// \brief ReadWrite map of the edges. |
1198 /// |
1198 /// |
1199 /// ReadWrite map of the edges. |
1199 /// ReadWrite map of the edges. |
1200 /// |
1200 /// |
1201 template <typename _Value> |
1201 template <typename _Value> |
1202 class EdgeMap : public GraphMap<Graph, Edge, _Value> { |
1202 class EdgeMap : public GraphMap<Graph, Edge, _Value> { |
1203 public: |
1203 public: |
1204 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent; |
1204 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent; |
1205 |
1205 |
1206 /// \brief Construct a new map. |
1206 /// \brief Construct a new map. |
1207 /// |
1207 /// |
1208 /// Construct a new map for the graph. |
1208 /// Construct a new map for the graph. |
1209 explicit EdgeMap(const MappableGraphComponent& graph) |
1209 explicit EdgeMap(const MappableGraphComponent& graph) |
1210 : Parent(graph) {} |
1210 : Parent(graph) {} |
1211 |
1211 |
1212 /// \brief Construct a new map with default value. |
1212 /// \brief Construct a new map with default value. |
1213 /// |
1213 /// |
1214 /// Construct a new map for the graph and initalise the values. |
1214 /// Construct a new map for the graph and initalise the values. |
1215 EdgeMap(const MappableGraphComponent& graph, const _Value& value) |
1215 EdgeMap(const MappableGraphComponent& graph, const _Value& value) |
1216 : Parent(graph, value) {} |
1216 : Parent(graph, value) {} |
1217 |
1217 |
1218 /// \brief Copy constructor. |
1218 /// \brief Copy constructor. |
1219 /// |
1219 /// |
1220 /// Copy Constructor. |
1220 /// Copy Constructor. |
1221 EdgeMap(const EdgeMap& nm) : Parent(nm) {} |
1221 EdgeMap(const EdgeMap& nm) : Parent(nm) {} |
1222 |
1222 |
1223 /// \brief Assign operator. |
1223 /// \brief Assign operator. |
1224 /// |
1224 /// |
1225 /// Assign operator. |
1225 /// Assign operator. |
1226 template <typename CMap> |
1226 template <typename CMap> |
1227 EdgeMap& operator=(const CMap&) { |
1227 EdgeMap& operator=(const CMap&) { |
1228 checkConcept<ReadMap<Edge, _Value>, CMap>(); |
1228 checkConcept<ReadMap<Edge, _Value>, CMap>(); |
1229 return *this; |
1229 return *this; |
1230 } |
1230 } |
1231 |
1231 |
1232 }; |
1232 }; |
1233 |
1233 |
1234 |
1234 |
1235 template <typename _Graph> |
1235 template <typename _Graph> |
1236 struct Constraints { |
1236 struct Constraints { |
1237 |
1237 |
1238 struct Dummy { |
1238 struct Dummy { |
1239 int value; |
1239 int value; |
1240 Dummy() : value(0) {} |
1240 Dummy() : value(0) {} |
1241 Dummy(int _v) : value(_v) {} |
1241 Dummy(int _v) : value(_v) {} |
1242 }; |
1242 }; |
1243 |
1243 |
1244 void constraints() { |
1244 void constraints() { |
1245 checkConcept<MappableGraphComponent<Base>, _Graph>(); |
1245 checkConcept<MappableGraphComponent<Base>, _Graph>(); |
1246 |
1246 |
1247 { // int map test |
1247 { // int map test |
1248 typedef typename _Graph::template EdgeMap<int> IntEdgeMap; |
1248 typedef typename _Graph::template EdgeMap<int> IntEdgeMap; |
1249 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>, |
1249 checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>, |
1250 IntEdgeMap >(); |
1250 IntEdgeMap >(); |
1251 } { // bool map test |
1251 } { // bool map test |
1252 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap; |
1252 typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap; |
1253 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>, |
1253 checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>, |
1254 BoolEdgeMap >(); |
1254 BoolEdgeMap >(); |
1255 } { // Dummy map test |
1255 } { // Dummy map test |
1256 typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap; |
1256 typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap; |
1257 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>, |
1257 checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>, |
1258 DummyEdgeMap >(); |
1258 DummyEdgeMap >(); |
1259 } |
1259 } |
1260 } |
1260 } |
1261 |
1261 |
1262 _Graph& graph; |
1262 _Graph& graph; |
1263 }; |
1263 }; |
1264 }; |
1264 }; |
1265 |
1265 |
1266 /// \brief An empty extendable digraph class. |
1266 /// \brief An empty extendable digraph class. |
1267 /// |
1267 /// |
1280 /// \brief Adds a new node to the digraph. |
1280 /// \brief Adds a new node to the digraph. |
1281 /// |
1281 /// |
1282 /// Adds a new node to the digraph. |
1282 /// Adds a new node to the digraph. |
1283 /// |
1283 /// |
1284 Node addNode() { |
1284 Node addNode() { |
1285 return INVALID; |
1285 return INVALID; |
1286 } |
1286 } |
1287 |
1287 |
1288 /// \brief Adds a new arc connects the given two nodes. |
1288 /// \brief Adds a new arc connects the given two nodes. |
1289 /// |
1289 /// |
1290 /// Adds a new arc connects the the given two nodes. |
1290 /// Adds a new arc connects the the given two nodes. |
1291 Arc addArc(const Node&, const Node&) { |
1291 Arc addArc(const Node&, const Node&) { |
1292 return INVALID; |
1292 return INVALID; |
1293 } |
1293 } |
1294 |
1294 |
1295 template <typename _Digraph> |
1295 template <typename _Digraph> |
1296 struct Constraints { |
1296 struct Constraints { |
1297 void constraints() { |
1297 void constraints() { |
1298 checkConcept<Base, _Digraph>(); |
1298 checkConcept<Base, _Digraph>(); |
1299 typename _Digraph::Node node_a, node_b; |
1299 typename _Digraph::Node node_a, node_b; |
1300 node_a = digraph.addNode(); |
1300 node_a = digraph.addNode(); |
1301 node_b = digraph.addNode(); |
1301 node_b = digraph.addNode(); |
1302 typename _Digraph::Arc arc; |
1302 typename _Digraph::Arc arc; |
1303 arc = digraph.addArc(node_a, node_b); |
1303 arc = digraph.addArc(node_a, node_b); |
1304 } |
1304 } |
1305 |
1305 |
1306 _Digraph& digraph; |
1306 _Digraph& digraph; |
1307 }; |
1307 }; |
1308 }; |
1308 }; |
1309 |
1309 |
1310 /// \brief An empty extendable base undirected graph class. |
1310 /// \brief An empty extendable base undirected graph class. |
1311 /// |
1311 /// |
1325 /// \brief Adds a new node to the graph. |
1325 /// \brief Adds a new node to the graph. |
1326 /// |
1326 /// |
1327 /// Adds a new node to the graph. |
1327 /// Adds a new node to the graph. |
1328 /// |
1328 /// |
1329 Node addNode() { |
1329 Node addNode() { |
1330 return INVALID; |
1330 return INVALID; |
1331 } |
1331 } |
1332 |
1332 |
1333 /// \brief Adds a new arc connects the given two nodes. |
1333 /// \brief Adds a new arc connects the given two nodes. |
1334 /// |
1334 /// |
1335 /// Adds a new arc connects the the given two nodes. |
1335 /// Adds a new arc connects the the given two nodes. |
1336 Edge addArc(const Node&, const Node&) { |
1336 Edge addArc(const Node&, const Node&) { |
1337 return INVALID; |
1337 return INVALID; |
1338 } |
1338 } |
1339 |
1339 |
1340 template <typename _Graph> |
1340 template <typename _Graph> |
1341 struct Constraints { |
1341 struct Constraints { |
1342 void constraints() { |
1342 void constraints() { |
1343 checkConcept<Base, _Graph>(); |
1343 checkConcept<Base, _Graph>(); |
1344 typename _Graph::Node node_a, node_b; |
1344 typename _Graph::Node node_a, node_b; |
1345 node_a = graph.addNode(); |
1345 node_a = graph.addNode(); |
1346 node_b = graph.addNode(); |
1346 node_b = graph.addNode(); |
1347 typename _Graph::Edge edge; |
1347 typename _Graph::Edge edge; |
1348 edge = graph.addEdge(node_a, node_b); |
1348 edge = graph.addEdge(node_a, node_b); |
1349 } |
1349 } |
1350 |
1350 |
1351 _Graph& graph; |
1351 _Graph& graph; |
1352 }; |
1352 }; |
1353 }; |
1353 }; |
1354 |
1354 |
1355 /// \brief An empty erasable digraph class. |
1355 /// \brief An empty erasable digraph class. |
1356 /// |
1356 /// |
1357 /// This class provides beside the core digraph features core erase |
1357 /// This class provides beside the core digraph features core erase |
1358 /// functions for the digraph structure. The main difference between |
1358 /// functions for the digraph structure. The main difference between |
1359 /// the base and this interface is that the digraph alterations |
1359 /// the base and this interface is that the digraph alterations |
1360 /// should handled already on this level. |
1360 /// should handled already on this level. |
1361 template <typename _Base = BaseDigraphComponent> |
1361 template <typename _Base = BaseDigraphComponent> |
1366 typedef typename Base::Node Node; |
1366 typedef typename Base::Node Node; |
1367 typedef typename Base::Arc Arc; |
1367 typedef typename Base::Arc Arc; |
1368 |
1368 |
1369 /// \brief Erase a node from the digraph. |
1369 /// \brief Erase a node from the digraph. |
1370 /// |
1370 /// |
1371 /// Erase a node from the digraph. This function should |
1371 /// Erase a node from the digraph. This function should |
1372 /// erase all arcs connecting to the node. |
1372 /// erase all arcs connecting to the node. |
1373 void erase(const Node&) {} |
1373 void erase(const Node&) {} |
1374 |
1374 |
1375 /// \brief Erase an arc from the digraph. |
1375 /// \brief Erase an arc from the digraph. |
1376 /// |
1376 /// |
1377 /// Erase an arc from the digraph. |
1377 /// Erase an arc from the digraph. |
1378 /// |
1378 /// |
1379 void erase(const Arc&) {} |
1379 void erase(const Arc&) {} |
1380 |
1380 |
1381 template <typename _Digraph> |
1381 template <typename _Digraph> |
1382 struct Constraints { |
1382 struct Constraints { |
1383 void constraints() { |
1383 void constraints() { |
1384 checkConcept<Base, _Digraph>(); |
1384 checkConcept<Base, _Digraph>(); |
1385 typename _Digraph::Node node; |
1385 typename _Digraph::Node node; |
1386 digraph.erase(node); |
1386 digraph.erase(node); |
1387 typename _Digraph::Arc arc; |
1387 typename _Digraph::Arc arc; |
1388 digraph.erase(arc); |
1388 digraph.erase(arc); |
1389 } |
1389 } |
1390 |
1390 |
1391 _Digraph& digraph; |
1391 _Digraph& digraph; |
1392 }; |
1392 }; |
1393 }; |
1393 }; |
1394 |
1394 |
1395 /// \brief An empty erasable base undirected graph class. |
1395 /// \brief An empty erasable base undirected graph class. |
1396 /// |
1396 /// |
1397 /// This class provides beside the core undirected graph features |
1397 /// This class provides beside the core undirected graph features |
1398 /// core erase functions for the undirceted graph structure. The |
1398 /// core erase functions for the undirceted graph structure. The |
1399 /// main difference between the base and this interface is that |
1399 /// main difference between the base and this interface is that |
1400 /// the graph alterations should handled already on this level. |
1400 /// the graph alterations should handled already on this level. |
1401 template <typename _Base = BaseGraphComponent> |
1401 template <typename _Base = BaseGraphComponent> |
1408 |
1408 |
1409 /// \brief Erase a node from the graph. |
1409 /// \brief Erase a node from the graph. |
1410 /// |
1410 /// |
1411 /// Erase a node from the graph. This function should erase |
1411 /// Erase a node from the graph. This function should erase |
1412 /// arcs connecting to the node. |
1412 /// arcs connecting to the node. |
1413 void erase(const Node&) {} |
1413 void erase(const Node&) {} |
1414 |
1414 |
1415 /// \brief Erase an arc from the graph. |
1415 /// \brief Erase an arc from the graph. |
1416 /// |
1416 /// |
1417 /// Erase an arc from the graph. |
1417 /// Erase an arc from the graph. |
1418 /// |
1418 /// |
1419 void erase(const Edge&) {} |
1419 void erase(const Edge&) {} |
1420 |
1420 |
1421 template <typename _Graph> |
1421 template <typename _Graph> |
1422 struct Constraints { |
1422 struct Constraints { |
1423 void constraints() { |
1423 void constraints() { |
1424 checkConcept<Base, _Graph>(); |
1424 checkConcept<Base, _Graph>(); |
1425 typename _Graph::Node node; |
1425 typename _Graph::Node node; |
1426 graph.erase(node); |
1426 graph.erase(node); |
1427 typename _Graph::Edge edge; |
1427 typename _Graph::Edge edge; |
1428 graph.erase(edge); |
1428 graph.erase(edge); |
1429 } |
1429 } |
1430 |
1430 |
1431 _Graph& graph; |
1431 _Graph& graph; |
1432 }; |
1432 }; |
1433 }; |
1433 }; |
1434 |
1434 |
1435 /// \brief An empty clearable base digraph class. |
1435 /// \brief An empty clearable base digraph class. |
1436 /// |
1436 /// |