COIN-OR::LEMON - Graph Library

source: lemon-0.x/lemon/concept/graph_components.h @ 2181:b2c38f4f72ff

Last change on this file since 2181:b2c38f4f72ff was 2181:b2c38f4f72ff, checked in by Balazs Dezso, 13 years ago

Omit warnings

File size: 50.6 KB
RevLine 
[2126]1/* -*- C++ -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library
4 *
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
12 *
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
15 * purpose.
16 *
17 */
18
19///\ingroup graph_concepts
20///\file
21///\brief The concept of the graph components.
22
23
24#ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H
25#define LEMON_CONCEPT_GRAPH_COMPONENTS_H
26
27#include <lemon/bits/invalid.h>
28#include <lemon/concept/maps.h>
29
30#include <lemon/bits/alteration_notifier.h>
31
32namespace lemon {
33  namespace concept {
34
35    /// \brief Skeleton class for graph Node and Edge types
36    ///
37    /// This class describes the interface of Node and Edge (and UEdge
38    /// in undirected graphs) subtypes of graph types.
39    ///
40    /// \note This class is a template class so that we can use it to
41    /// create graph skeleton classes. The reason for this is than Node
42    /// and Edge types should \em not derive from the same base class.
43    /// For Node you should instantiate it with character 'n' and for Edge
44    /// with 'e'.
45
46#ifndef DOXYGEN
47    template <char _selector = '0'>
48#endif
49    class GraphItem {
50    public:
51      /// \brief Default constructor.
52      ///     
53      /// \warning The default constructor is not required to set
54      /// the item to some well-defined value. So you should consider it
55      /// as uninitialized.
56      GraphItem() {}
57      /// \brief Copy constructor.
58      ///
59      /// Copy constructor.
60      ///
61      GraphItem(const GraphItem &) {}
62      /// \brief Invalid constructor \& conversion.
63      ///
64      /// This constructor initializes the item to be invalid.
65      /// \sa Invalid for more details.
66      GraphItem(Invalid) {}
67      /// \brief Assign operator for nodes.
68      ///
69      /// The nodes are assignable.
70      ///
71      GraphItem& operator=(GraphItem const&) { return *this; }
72      /// \brief Equality operator.
73      ///
74      /// Two iterators are equal if and only if they represents the
75      /// same node in the graph or both are invalid.
76      bool operator==(GraphItem) const { return false; }
77      /// \brief Inequality operator.
78      ///
79      /// \sa operator==(const Node& n)
80      ///
81      bool operator!=(GraphItem) const { return false; }
82
83      /// \brief Artificial ordering operator.
84      ///
85      /// To allow the use of graph descriptors as key type in std::map or
86      /// similar associative container we require this.
87      ///
88      /// \note This operator only have to define some strict ordering of
89      /// the items; this order has nothing to do with the iteration
90      /// ordering of the items.
91      bool operator<(GraphItem) const { return false; }
92
93      template<typename _GraphItem>
94      struct Constraints {
95        void constraints() {
96          _GraphItem i1;
97          _GraphItem i2 = i1;
98          _GraphItem i3 = INVALID;
99         
100          i1 = i2 = i3;
101
102          bool b;
103          //      b = (ia == ib) && (ia != ib) && (ia < ib);
104          b = (ia == ib) && (ia != ib);
105          b = (ia == INVALID) && (ib != INVALID);
106          b = (ia < ib);
107        }
108
109        const _GraphItem &ia;
110        const _GraphItem &ib;
111      };
112    };
113
114    /// \brief An empty base graph class.
115    /// 
116    /// This class provides the minimal set of features needed for a graph
117    /// structure. All graph concepts have to be conform to this base
118    /// graph. It just provides types for nodes and edges and functions to
119    /// get the source and the target of the edges.
120    class BaseGraphComponent {
121    public:
122
123      typedef BaseGraphComponent Graph;
124     
125      /// \brief Node class of the graph.
126      ///
127      /// This class represents the Nodes of the graph.
128      ///
129      typedef GraphItem<'n'> Node;
130
131      /// \brief Edge class of the graph.
132      ///
133      /// This class represents the Edges of the graph.
134      ///
135      typedef GraphItem<'e'> Edge;
136
137      /// \brief Gives back the target node of an edge.
138      ///
139      /// Gives back the target node of an edge.
140      ///
141      Node target(const Edge&) const { return INVALID;}
142
143      /// \brief Gives back the source node of an edge.
144      ///
145      /// Gives back the source node of an edge.
146      ///
147      Node source(const Edge&) const { return INVALID;}
148
149      /// \brief Gives back the opposite node on the given edge.
150      ///
151      /// Gives back the opposite node on the given edge.
152      Node oppositeNode(const Node&, const Edge&) const {
153        return INVALID;
154      }
155
156      template <typename _Graph>
157      struct Constraints {
158        typedef typename _Graph::Node Node;
159        typedef typename _Graph::Edge Edge;
160     
161        void constraints() {
162          checkConcept<GraphItem<'n'>, Node>();
163          checkConcept<GraphItem<'e'>, Edge>();
164          {
165            Node n;
166            Edge e(INVALID);
167            n = graph.source(e);
168            n = graph.target(e);
169            n = graph.oppositeNode(n, e);
170          }     
171        }
172     
173        const _Graph& graph;
174      };
175    };
176
177    /// \brief An empty base undirected graph class.
178    /// 
179    /// This class provides the minimal set of features needed for an
180    /// undirected graph structure. All undirected graph concepts have
181    /// to be conform to this base graph. It just provides types for
182    /// nodes, edges and undirected edges and functions to get the
183    /// source and the target of the edges and undirected edges,
184    /// conversion from edges to undirected edges and function to get
185    /// both direction of the undirected edges.
186    class BaseUGraphComponent : public BaseGraphComponent {
187    public:
188      typedef BaseGraphComponent::Node Node;
189      typedef BaseGraphComponent::Edge Edge;
190      /// \brief Undirected edge class of the graph.
191      ///
192      /// This class represents the undirected edges of the graph.
193      /// The undirected graphs can be used as a directed graph which
194      /// for each edge contains the opposite edge too so the graph is
195      /// bidirected. The undirected edge represents two opposite
196      /// directed edges.
197      class UEdge : public GraphItem<'u'> {
198      public:
199        typedef GraphItem<'u'> Parent;
200        /// \brief Default constructor.
201        ///     
202        /// \warning The default constructor is not required to set
203        /// the item to some well-defined value. So you should consider it
204        /// as uninitialized.
205        UEdge() {}
206        /// \brief Copy constructor.
207        ///
208        /// Copy constructor.
209        ///
210        UEdge(const UEdge &) : Parent() {}
211        /// \brief Invalid constructor \& conversion.
212        ///
213        /// This constructor initializes the item to be invalid.
214        /// \sa Invalid for more details.
215        UEdge(Invalid) {}
216        /// \brief Converter from edge to undirected edge.
217        ///
218        /// Besides the core graph item functionality each edge should
219        /// be convertible to the represented undirected edge.
220        UEdge(const Edge&) {}
221      };
222
223      /// \brief Returns the direction of the edge.
224      ///
225      /// Returns the direction of the edge. Each edge represents an
226      /// undirected edge with a direction. It gives back the
227      /// direction.
228      bool direction(const Edge&) const { return true; }
229
230      /// \brief Returns the directed edge.
231      ///
232      /// Returns the directed edge from its direction and the
233      /// represented undirected edge.
234      Edge direct(const UEdge&, bool) const { return INVALID;}
235
236      /// \brief Returns the directed edge.
237      ///
238      /// Returns the directed edge from its source and the
239      /// represented undirected edge.
240      Edge direct(const UEdge&, const Node&) const { return INVALID;}
241
242      /// \brief Returns the opposite edge.
243      ///
244      /// Returns the opposite edge. It is the edge representing the
245      /// same undirected edge and has opposite direction.
246      Edge oppositeEdge(const Edge&) const { return INVALID;}
247
248      /// \brief Gives back the target node of an undirected edge.
249      ///
250      /// Gives back the target node of an undirected edge. The name
251      /// target is a little confusing because the undirected edge
252      /// does not have target but it just means that one of the end
253      /// node.
254      Node target(const UEdge&) const { return INVALID;}
255
256      /// \brief Gives back the source node of an undirected edge.
257      ///
258      /// Gives back the source node of an undirected edge. The name
259      /// source is a little confusing because the undirected edge
260      /// does not have source but it just means that one of the end
261      /// node.
262      Node source(const UEdge&) const { return INVALID;}
263     
264      template <typename _Graph>
265      struct Constraints {
266        typedef typename _Graph::Node Node;
267        typedef typename _Graph::Edge Edge;
268        typedef typename _Graph::UEdge UEdge;
269     
270        void constraints() {
271          checkConcept<BaseGraphComponent, _Graph>();
272          checkConcept<GraphItem<'u'>, UEdge>();
273          {
274            Node n;
275            UEdge ue(INVALID);
276            Edge e;
277            n = graph.source(ue);
278            n = graph.target(ue);
279            e = graph.direct(ue, true);
280            e = graph.direct(ue, n);
281            e = graph.oppositeEdge(e);
282            ue = e;
283            bool d = graph.direction(e);
284            ignore_unused_variable_warning(d);
285          }     
286        }
287     
288        const _Graph& graph;
289      };
290
291    };
292
293    /// \brief An empty iterable base graph class.
294    /// 
295    /// This class provides beside the core graph features
296    /// core iterable interface for the graph structure.
297    /// Most of the base graphs should be conform to this concept.
298    template <typename _Base = BaseGraphComponent>
299    class BaseIterableGraphComponent : public _Base {
300    public:
301
302      typedef _Base Base;
303      typedef typename Base::Node Node;
304      typedef typename Base::Edge Edge;
305
306      /// \brief Gives back the first node in the iterating order.
307      ///     
308      /// Gives back the first node in the iterating order.
309      ///     
310      void first(Node&) const {}
311
312      /// \brief Gives back the next node in the iterating order.
313      ///
314      /// Gives back the next node in the iterating order.
315      ///     
316      void next(Node&) const {}
317
318      /// \brief Gives back the first edge in the iterating order.
319      ///
320      /// Gives back the first edge in the iterating order.
321      ///     
322      void first(Edge&) const {}
323
324      /// \brief Gives back the next edge in the iterating order.
325      ///
326      /// Gives back the next edge in the iterating order.
327      ///     
328      void next(Edge&) const {}
329
330
331      /// \brief Gives back the first of the edges point to the given
332      /// node.
333      ///
334      /// Gives back the first of the edges point to the given node.
335      ///     
336      void firstIn(Edge&, const Node&) const {}
337
338      /// \brief Gives back the next of the edges points to the given
339      /// node.
340      ///
341      /// Gives back the next of the edges points to the given node.
342      ///
343      void nextIn(Edge&) const {}
344
345      /// \brief Gives back the first of the edges start from the
346      /// given node.
347      ///     
348      /// Gives back the first of the edges start from the given node.
349      ///     
350      void firstOut(Edge&, const Node&) const {}
351
352      /// \brief Gives back the next of the edges start from the given
353      /// node.
354      ///
355      /// Gives back the next of the edges start from the given node.
356      ///     
357      void nextOut(Edge&) const {}
358
359
360      template <typename _Graph>
361      struct Constraints {
362     
363        void constraints() {
364          checkConcept< BaseGraphComponent, _Graph >();
[2129]365          typename _Graph::Node node(INVALID);     
366          typename _Graph::Edge edge(INVALID);
[2126]367          {
368            graph.first(node);
369            graph.next(node);
370          }
371          {
372            graph.first(edge);
373            graph.next(edge);
374          }
375          {
376            graph.firstIn(edge, node);
377            graph.nextIn(edge);
378          }
379          {
380            graph.firstOut(edge, node);
381            graph.nextOut(edge);
382          }
383        }
384
385        const _Graph& graph;
386      };
387    };
388
389    /// \brief An empty iterable base undirected graph class.
390    /// 
391    /// This class provides beside the core undirceted graph features
392    /// core iterable interface for the undirected graph structure.
393    /// Most of the base undirected graphs should be conform to this
394    /// concept.
395    template <typename _Base = BaseUGraphComponent>
396    class BaseIterableUGraphComponent
397      : public BaseIterableGraphComponent<_Base> {
398    public:
399
400      typedef _Base Base;
401      typedef typename Base::UEdge UEdge;
402      typedef typename Base::Node Node;
403
404      using BaseIterableGraphComponent<_Base>::first;
405      using BaseIterableGraphComponent<_Base>::next;
406
407      /// \brief Gives back the first undirected edge in the iterating
408      /// order.
409      ///
410      /// Gives back the first undirected edge in the iterating order.
411      ///     
412      void first(UEdge&) const {}
413
414      /// \brief Gives back the next undirected edge in the iterating
415      /// order.
416      ///
417      /// Gives back the next undirected edge in the iterating order.
418      ///     
419      void next(UEdge&) const {}
420
421
422      /// \brief Gives back the first of the undirected edges from the
423      /// given node.
424      ///
425      /// Gives back the first of the undirected edges from the given
426      /// node. The bool parameter gives back that direction which
427      /// gives a good direction of the uedge so the source of the
428      /// directed edge is the given node.
429      void firstInc(UEdge&, bool&, const Node&) const {}
430
431      /// \brief Gives back the next of the undirected edges from the
432      /// given node.
433      ///
434      /// Gives back the next of the undirected edges from the given
435      /// node. The bool parameter should be used as the \c firstInc()
436      /// use it.
437      void nextInc(UEdge&, bool&) const {}
438
439      template <typename _Graph>
440      struct Constraints {
441     
442        void constraints() {
443          checkConcept<Base, _Graph >();
444          checkConcept<BaseIterableGraphComponent<Base>, _Graph>();
[2129]445          typename _Graph::Node node(INVALID);
446          typename _Graph::UEdge uedge(INVALID);
[2126]447          bool dir;
448          {
449            graph.first(uedge);
450            graph.next(uedge);
451          }
452          {
453            graph.firstInc(uedge, dir, node);
454            graph.nextInc(uedge, dir);
455          }
456        }
457
458        const _Graph& graph;
459      };
460    };
461
462    /// \brief An empty idable base graph class.
463    /// 
464    /// This class provides beside the core graph features
465    /// core id functions for the graph structure.
466    /// The most of the base graphs should be conform to this concept.
467    /// The id's are unique and immutable.
468    template <typename _Base = BaseGraphComponent>
469    class IDableGraphComponent : public _Base {
470    public:
471
472      typedef _Base Base;
473      typedef typename Base::Node Node;
474      typedef typename Base::Edge Edge;
475
476      /// \brief Gives back an unique integer id for the Node.
477      ///
478      /// Gives back an unique integer id for the Node.
479      ///
480      int id(const Node&) const { return -1;}
481
482      /// \brief Gives back the node by the unique id.
483      ///
484      /// Gives back the node by the unique id.
485      /// If the graph does not contain node with the given id
486      /// then the result of the function is undetermined.
487      Node nodeFromId(int) const { return INVALID;}
488
489      /// \brief Gives back an unique integer id for the Edge.
490      ///
491      /// Gives back an unique integer id for the Edge.
492      ///
493      int id(const Edge&) const { return -1;}
494
495      /// \brief Gives back the edge by the unique id.
496      ///
497      /// Gives back the edge by the unique id.
498      /// If the graph does not contain edge with the given id
499      /// then the result of the function is undetermined.
500      Edge edgeFromId(int) const { return INVALID;}
501
502      /// \brief Gives back an integer greater or equal to the maximum
503      /// Node id.
504      ///
505      /// Gives back an integer greater or equal to the maximum Node
506      /// id.
507      int maxNodeId() const { return -1;}
508
509      /// \brief Gives back an integer greater or equal to the maximum
510      /// Edge id.
511      ///
512      /// Gives back an integer greater or equal to the maximum Edge
513      /// id.
514      int maxEdgeId() const { return -1;}
515
516      template <typename _Graph>
517      struct Constraints {
518
519        void constraints() {
520          checkConcept< BaseGraphComponent, _Graph >();
521          typename _Graph::Node node;
522          int nid = graph.id(node);
523          nid = graph.id(node);
524          node = graph.nodeFromId(nid);
525          typename _Graph::Edge edge;
526          int eid = graph.id(edge);
527          eid = graph.id(edge);
528          edge = graph.edgeFromId(eid);
529
530          nid = graph.maxNodeId();
531          ignore_unused_variable_warning(nid);
532          eid = graph.maxEdgeId();
533          ignore_unused_variable_warning(eid);
534        }
535
536        const _Graph& graph;
537      };
538    };
539
540    /// \brief An empty idable base undirected graph class.
541    /// 
542    /// This class provides beside the core undirected graph features
543    /// core id functions for the undirected graph structure.  The
544    /// most of the base undirected graphs should be conform to this
545    /// concept.  The id's are unique and immutable.
546    template <typename _Base = BaseUGraphComponent>
547    class IDableUGraphComponent : public IDableGraphComponent<_Base> {
548    public:
549
550      typedef _Base Base;
551      typedef typename Base::UEdge UEdge;
552
553      using IDableGraphComponent<_Base>::id;
554
555      /// \brief Gives back an unique integer id for the UEdge.
556      ///
557      /// Gives back an unique integer id for the UEdge.
558      ///
559      int id(const UEdge&) const { return -1;}
560
561      /// \brief Gives back the undirected edge by the unique id.
562      ///
563      /// Gives back the undirected edge by the unique id.  If the
564      /// graph does not contain edge with the given id then the
565      /// result of the function is undetermined.
566      UEdge uEdgeFromId(int) const { return INVALID;}
567
568      /// \brief Gives back an integer greater or equal to the maximum
569      /// UEdge id.
570      ///
571      /// Gives back an integer greater or equal to the maximum UEdge
572      /// id.
573      int maxUEdgeId() const { return -1;}
574
575      template <typename _Graph>
576      struct Constraints {
577
578        void constraints() {
579          checkConcept<Base, _Graph >();
580          checkConcept<IDableGraphComponent<Base>, _Graph >();
581          typename _Graph::UEdge uedge;
582          int ueid = graph.id(uedge);
583          ueid = graph.id(uedge);
584          uedge = graph.uEdgeFromId(ueid);
585          ueid = graph.maxUEdgeId();
586          ignore_unused_variable_warning(ueid);
587        }
588
589        const _Graph& graph;
590      };
591    };
592
593    /// \brief An empty extendable base graph class.
594    ///
595    /// This class provides beside the core graph features
596    /// core graph extend interface for the graph structure.
597    /// The most of the base graphs should be conform to this concept.
598    template <typename _Base = BaseGraphComponent>
599    class BaseExtendableGraphComponent : public _Base {
600    public:
601
602      typedef typename _Base::Node Node;
603      typedef typename _Base::Edge Edge;
604
605      /// \brief Adds a new node to the graph.
606      ///
607      /// Adds a new node to the graph.
608      ///
609      Node addNode() {
610        return INVALID;
611      }
612   
613      /// \brief Adds a new edge connects the given two nodes.
614      ///
615      /// Adds a new edge connects the the given two nodes.
616      Edge addEdge(const Node&, const Node&) {
617        return INVALID;
618      }
619
620      template <typename _Graph>
621      struct Constraints {
622        void constraints() {
623          typename _Graph::Node node_a, node_b;
624          node_a = graph.addNode();
625          node_b = graph.addNode();
626          typename _Graph::Edge edge;
627          edge = graph.addEdge(node_a, node_b);
628        }
629
630        _Graph& graph;
631      };
632    };
633
634    /// \brief An empty extendable base undirected graph class.
635    ///
636    /// This class provides beside the core undirected graph features
637    /// core undircted graph extend interface for the graph structure.
638    /// The most of the base graphs should be conform to this concept.
639    template <typename _Base = BaseUGraphComponent>
640    class BaseExtendableUGraphComponent : public _Base {
641    public:
642
643      typedef typename _Base::Node Node;
644      typedef typename _Base::UEdge UEdge;
645
646      /// \brief Adds a new node to the graph.
647      ///
648      /// Adds a new node to the graph.
649      ///
650      Node addNode() {
651        return INVALID;
652      }
653   
654      /// \brief Adds a new edge connects the given two nodes.
655      ///
656      /// Adds a new edge connects the the given two nodes.
657      UEdge addEdge(const Node&, const Node&) {
658        return INVALID;
659      }
660
661      template <typename _Graph>
662      struct Constraints {
663        void constraints() {
664          typename _Graph::Node node_a, node_b;
665          node_a = graph.addNode();
666          node_b = graph.addNode();
667          typename _Graph::UEdge uedge;
668          uedge = graph.addUEdge(node_a, node_b);
669        }
670
671        _Graph& graph;
672      };
673    };
674
675    /// \brief An empty erasable base graph class.
676    /// 
677    /// This class provides beside the core graph features
678    /// core erase functions for the graph structure.
679    /// The most of the base graphs should be conform to this concept.
680    template <typename _Base = BaseGraphComponent>
681    class BaseErasableGraphComponent : public _Base {
682    public:
683
684      typedef _Base Base;
685      typedef typename Base::Node Node;
686      typedef typename Base::Edge Edge;
687
688      /// \brief Erase a node from the graph.
689      ///
690      /// Erase a node from the graph. This function should not
691      /// erase edges connecting to the Node.
692      void erase(const Node&) {}   
693
694      /// \brief Erase an edge from the graph.
695      ///
696      /// Erase an edge from the graph.
697      ///
698      void erase(const Edge&) {}
699
700      template <typename _Graph>
701      struct Constraints {
702        void constraints() {
703          typename _Graph::Node node;
704          graph.erase(node);
705          typename _Graph::Edge edge;
706          graph.erase(edge);
707        }
708
709        _Graph& graph;
710      };
711    };
712
713    /// \brief An empty erasable base undirected graph class.
714    /// 
715    /// This class provides beside the core undirected graph features
716    /// core erase functions for the undirceted graph structure.
717    template <typename _Base = BaseUGraphComponent>
718    class BaseErasableUGraphComponent : public _Base {
719    public:
720
721      typedef _Base Base;
722      typedef typename Base::Node Node;
723      typedef typename Base::UEdge UEdge;
724
725      /// \brief Erase a node from the graph.
726      ///
727      /// Erase a node from the graph. This function should not
728      /// erase edges connecting to the Node.
729      void erase(const Node&) {}   
730
731      /// \brief Erase an edge from the graph.
732      ///
733      /// Erase an edge from the graph.
734      ///
735      void erase(const UEdge&) {}
736
737      template <typename _Graph>
738      struct Constraints {
739        void constraints() {
740          typename _Graph::Node node;
741          graph.erase(node);
742          typename _Graph::Edge edge;
743          graph.erase(edge);
744        }
745
746        _Graph& graph;
747      };
748    };
749
750    /// \brief An empty clearable base graph class.
751    ///
752    /// This class provides beside the core graph features
753    /// core clear functions for the graph structure.
754    /// The most of the base graphs should be conform to this concept.
755    template <typename _Base = BaseGraphComponent>
756    class BaseClearableGraphComponent : public _Base {
757    public:
758
759      /// \brief Erase all the nodes and edges from the graph.
760      ///
761      /// Erase all the nodes and edges from the graph.
762      ///
763      void clear() {}   
764
765      template <typename _Graph>
766      struct Constraints {
767        void constraints() {
768          graph.clear();
769        }
770
771        _Graph graph;
772      };
773    };
774
775    /// \brief An empty clearable base undirected graph class.
776    ///
777    /// This class provides beside the core undirected graph features
778    /// core clear functions for the undirected graph structure.
779    /// The most of the base graphs should be conform to this concept.
780    template <typename _Base = BaseUGraphComponent>
781    class BaseClearableUGraphComponent : public _Base {
782    public:
783
784      /// \brief Erase all the nodes and undirected edges from the graph.
785      ///
786      /// Erase all the nodes and undirected edges from the graph.
787      ///
788      void clear() {}   
789
790      template <typename _Graph>
791      struct Constraints {
792        void constraints() {
793          graph.clear();
794        }
795
796        _Graph graph;
797      };
798    };
799
800
801    /// \brief Skeleton class for graph NodeIt and EdgeIt
802    ///
803    /// Skeleton class for graph NodeIt and EdgeIt.
804    ///
805    template <typename _Graph, typename _Item>
806    class GraphItemIt : public _Item {
807    public:
808      /// \brief Default constructor.
809      ///
810      /// @warning The default constructor sets the iterator
811      /// to an undefined value.
812      GraphItemIt() {}
813      /// \brief Copy constructor.
814      ///
815      /// Copy constructor.
816      ///
817      GraphItemIt(const GraphItemIt& ) {}
818      /// \brief Sets the iterator to the first item.
819      ///
820      /// Sets the iterator to the first item of \c the graph.
821      ///
822      explicit GraphItemIt(const _Graph&) {}
823      /// \brief Invalid constructor \& conversion.
824      ///
825      /// This constructor initializes the item to be invalid.
826      /// \sa Invalid for more details.
827      GraphItemIt(Invalid) {}
828      /// \brief Assign operator for items.
829      ///
830      /// The items are assignable.
831      ///
832      GraphItemIt& operator=(const GraphItemIt&) { return *this; }     
833      /// \brief Next item.
834      ///
835      /// Assign the iterator to the next item.
836      ///
837      GraphItemIt& operator++() { return *this; }
838      /// \brief Equality operator
839      ///
840      /// Two iterators are equal if and only if they point to the
841      /// same object or both are invalid.
842      bool operator==(const GraphItemIt&) const { return true;}
843      /// \brief Inequality operator
844      ///       
845      /// \sa operator==(Node n)
846      ///
847      bool operator!=(const GraphItemIt&) const { return true;}
848     
849      template<typename _GraphItemIt>
850      struct Constraints {
851        void constraints() {
852          _GraphItemIt it1(g); 
853          _GraphItemIt it2;
854
855          it2 = ++it1;
856          ++it2 = it1;
857          ++(++it1);
858
859          _Item bi = it1;
860          bi = it2;
861        }
862        _Graph& g;
863      };
864    };
865
866    /// \brief Skeleton class for graph InEdgeIt and OutEdgeIt
867    ///
868    /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
869    /// base class, the _selector is a additional template parameter. For
870    /// InEdgeIt you should instantiate it with character 'i' and for
871    /// OutEdgeIt with 'o'.
872    template <typename _Graph,
873              typename _Item = typename _Graph::Edge,
874              typename _Base = typename _Graph::Node,
875              char _selector = '0'>
876    class GraphIncIt : public _Item {
877    public:
878      /// \brief Default constructor.
879      ///
880      /// @warning The default constructor sets the iterator
881      /// to an undefined value.
882      GraphIncIt() {}
883      /// \brief Copy constructor.
884      ///
885      /// Copy constructor.
886      ///
887      GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
888      /// \brief Sets the iterator to the first edge incoming into or outgoing
889      /// from the node.
890      ///
891      /// Sets the iterator to the first edge incoming into or outgoing
892      /// from the node.
893      ///
894      explicit GraphIncIt(const _Graph&, const _Base&) {}
895      /// \brief Invalid constructor \& conversion.
896      ///
897      /// This constructor initializes the item to be invalid.
898      /// \sa Invalid for more details.
899      GraphIncIt(Invalid) {}
900      /// \brief Assign operator for iterators.
901      ///
902      /// The iterators are assignable.
903      ///
904      GraphIncIt& operator=(GraphIncIt const&) { return *this; }     
905      /// \brief Next item.
906      ///
907      /// Assign the iterator to the next item.
908      ///
909      GraphIncIt& operator++() { return *this; }
910
911      /// \brief Equality operator
912      ///
913      /// Two iterators are equal if and only if they point to the
914      /// same object or both are invalid.
915      bool operator==(const GraphIncIt&) const { return true;}
916
917      /// \brief Inequality operator
918      ///
919      /// \sa operator==(Node n)
920      ///
921      bool operator!=(const GraphIncIt&) const { return true;}
922
923      template <typename _GraphIncIt>
924      struct Constraints {
925        void constraints() {
926          checkConcept<GraphItem<_selector>, _GraphIncIt>();
927          _GraphIncIt it1(graph, node);
928          _GraphIncIt it2;
929
930          it2 = ++it1;
931          ++it2 = it1;
932          ++(++it1);
933          _Item e = it1;
934          e = it2;
935
936        }
937
938        _Item edge;
939        _Base node;
940        _Graph graph;
941        _GraphIncIt it;
942      };
943    };
944
945
946    /// \brief An empty iterable graph class.
947    ///
948    /// This class provides beside the core graph features
949    /// iterator based iterable interface for the graph structure.
950    /// This concept is part of the GraphConcept.
951    template <typename _Base = BaseGraphComponent>
952    class IterableGraphComponent : public _Base {
953
954    public:
955   
956      typedef _Base Base;
957      typedef typename Base::Node Node;
958      typedef typename Base::Edge Edge;
959
960      typedef IterableGraphComponent Graph;
961
962
963      /// \brief This iterator goes through each node.
964      ///
965      /// This iterator goes through each node.
966      ///
967      typedef GraphItemIt<Graph, Node> NodeIt;
968
969      /// \brief This iterator goes through each node.
970      ///
971      /// This iterator goes through each node.
972      ///
973      typedef GraphItemIt<Graph, Edge> EdgeIt;
974
975      /// \brief This iterator goes trough the incoming edges of a node.
976      ///
977      /// This iterator goes trough the \e inccoming edges of a certain node
978      /// of a graph.
979      typedef GraphIncIt<Graph, Edge, Node, 'i'> InEdgeIt;
980
981      /// \brief This iterator goes trough the outgoing edges of a node.
982      ///
983      /// This iterator goes trough the \e outgoing edges of a certain node
984      /// of a graph.
985      typedef GraphIncIt<Graph, Edge, Node, 'o'> OutEdgeIt;
986
987      /// \brief The base node of the iterator.
988      ///
989      /// Gives back the base node of the iterator.
990      /// It is always the target of the pointed edge.
991      Node baseNode(const InEdgeIt&) const { return INVALID; }
992
993      /// \brief The running node of the iterator.
994      ///
995      /// Gives back the running node of the iterator.
996      /// It is always the source of the pointed edge.
997      Node runningNode(const InEdgeIt&) const { return INVALID; }
998
999      /// \brief The base node of the iterator.
1000      ///
1001      /// Gives back the base node of the iterator.
1002      /// It is always the source of the pointed edge.
1003      Node baseNode(const OutEdgeIt&) const { return INVALID; }
1004
1005      /// \brief The running node of the iterator.
1006      ///
1007      /// Gives back the running node of the iterator.
1008      /// It is always the target of the pointed edge.
1009      Node runningNode(const OutEdgeIt&) const { return INVALID; }
1010
1011      /// \brief The opposite node on the given edge.
1012      ///
1013      /// Gives back the opposite on the given edge.
1014      /// \todo It should not be here.
1015      Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
1016
1017   
1018      template <typename _Graph>
1019      struct Constraints {
1020        void constraints() {
1021          checkConcept<Base, _Graph>();
1022         
1023          checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
1024            typename _Graph::EdgeIt >();
1025          checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
1026            typename _Graph::NodeIt >();
1027          checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
1028            typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
1029          checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
1030            typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
1031
1032          typename _Graph::Node n;
1033          typename _Graph::InEdgeIt ieit(INVALID);
1034          typename _Graph::OutEdgeIt oeit(INVALID);
1035          n = graph.baseNode(ieit);
1036          n = graph.runningNode(ieit);
1037          n = graph.baseNode(oeit);
1038          n = graph.runningNode(oeit);
1039          ignore_unused_variable_warning(n);
1040        }
1041       
1042        const _Graph& graph;
1043       
1044      };
1045    };
1046
1047    /// \brief An empty iterable undirected graph class.
1048    ///
1049    /// This class provides beside the core graph features iterator
1050    /// based iterable interface for the undirected graph structure.
1051    /// This concept is part of the GraphConcept.
1052    template <typename _Base = BaseUGraphComponent>
1053    class IterableUGraphComponent : public IterableGraphComponent<_Base> {
1054    public:
1055
1056      typedef _Base Base;
1057      typedef typename Base::Node Node;
1058      typedef typename Base::Edge Edge;
1059      typedef typename Base::UEdge UEdge;
1060
1061   
1062      typedef IterableUGraphComponent Graph;
1063      using IterableGraphComponent<_Base>::baseNode;
1064      using IterableGraphComponent<_Base>::runningNode;
1065
1066
1067      /// \brief This iterator goes through each node.
1068      ///
1069      /// This iterator goes through each node.
1070      typedef GraphItemIt<Graph, UEdge> UEdgeIt;
1071      /// \brief This iterator goes trough the incident edges of a
1072      /// node.
1073      ///
1074      /// This iterator goes trough the incident edges of a certain
1075      /// node of a graph.
1076      typedef GraphIncIt<Graph, UEdge, Node, 'u'> IncEdgeIt;
1077      /// \brief The base node of the iterator.
1078      ///
1079      /// Gives back the base node of the iterator.
1080      Node baseNode(const IncEdgeIt&) const { return INVALID; }
1081
1082      /// \brief The running node of the iterator.
1083      ///
1084      /// Gives back the running node of the iterator.
1085      Node runningNode(const IncEdgeIt&) const { return INVALID; }
1086
1087      template <typename _Graph>
1088      struct Constraints {
1089        void constraints() {
1090          checkConcept<Base, _Graph>();
1091          checkConcept<IterableGraphComponent<Base>, _Graph>();
1092         
1093          checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
1094            typename _Graph::UEdgeIt >();
1095          checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge,
1096            typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
1097
1098          typename _Graph::Node n;
1099          typename _Graph::IncEdgeIt ueit(INVALID);
1100          n = graph.baseNode(ueit);
1101          n = graph.runningNode(ueit);
1102        }
1103       
1104        const _Graph& graph;
1105       
1106      };
1107    };
1108
1109    /// \brief An empty alteration notifier graph class.
1110    /// 
1111    /// This class provides beside the core graph features alteration
1112    /// notifier interface for the graph structure.  This implements
1113    /// an observer-notifier pattern for each graph item. More
1114    /// obsevers can be registered into the notifier and whenever an
1115    /// alteration occured in the graph all the observers will
1116    /// notified about it.
1117    template <typename _Base = BaseGraphComponent>
1118    class AlterableGraphComponent : public _Base {
1119    public:
1120
1121      typedef _Base Base;
1122      typedef typename Base::Node Node;
1123      typedef typename Base::Edge Edge;
1124
1125
1126      /// The node observer registry.
1127      typedef AlterationNotifier<AlterableGraphComponent, Node>
1128      NodeNotifier;
1129      /// The edge observer registry.
1130      typedef AlterationNotifier<AlterableGraphComponent, Edge>
1131      EdgeNotifier;
1132     
1133      /// \brief Gives back the node alteration notifier.
1134      ///
1135      /// Gives back the node alteration notifier.
1136      NodeNotifier& getNotifier(Node) const {
1137        return NodeNotifier();
1138      }
1139     
1140      /// \brief Gives back the edge alteration notifier.
1141      ///
1142      /// Gives back the edge alteration notifier.
1143      EdgeNotifier& getNotifier(Edge) const {
1144        return EdgeNotifier();
1145      }
1146
1147      template <typename _Graph>
1148      struct Constraints {
1149        void constraints() {
1150          checkConcept<Base, _Graph>();
1151          typename _Graph::NodeNotifier& nn
1152            = graph.getNotifier(typename _Graph::Node());
1153
1154          typename _Graph::EdgeNotifier& en
1155            = graph.getNotifier(typename _Graph::Edge());
1156         
1157          ignore_unused_variable_warning(nn);
1158          ignore_unused_variable_warning(en);
1159        }
1160       
1161        const _Graph& graph;
1162       
1163      };
1164     
1165    };
1166
1167    /// \brief An empty alteration notifier undirected graph class.
1168    /// 
1169    /// This class provides beside the core graph features alteration
1170    /// notifier interface for the graph structure.  This implements
1171    /// an observer-notifier pattern for each graph item. More
1172    /// obsevers can be registered into the notifier and whenever an
1173    /// alteration occured in the graph all the observers will
1174    /// notified about it.
1175    template <typename _Base = BaseUGraphComponent>
1176    class AlterableUGraphComponent : public AlterableGraphComponent<_Base> {
1177    public:
1178
1179      typedef _Base Base;
1180      typedef typename Base::UEdge UEdge;
1181
1182
1183      /// The edge observer registry.
1184      typedef AlterationNotifier<AlterableUGraphComponent, UEdge>
1185      UEdgeNotifier;
1186     
1187      /// \brief Gives back the edge alteration notifier.
1188      ///
1189      /// Gives back the edge alteration notifier.
1190      UEdgeNotifier& getNotifier(UEdge) const {
1191        return UEdgeNotifier();
1192      }
1193
1194      template <typename _Graph>
1195      struct Constraints {
1196        void constraints() {
1197          checkConcept<Base, _Graph>();
1198          checkConcept<AlterableGraphComponent, _Graph>();
1199          typename _Graph::UEdgeNotifier& uen
1200            = graph.getNotifier(typename _Graph::UEdge());
1201          ignore_unused_variable_warning(uen);
1202        }
1203       
1204        const _Graph& graph;
1205       
1206      };
1207     
1208    };
1209
1210
1211    /// \brief Class describing the concept of graph maps
1212    ///
1213    /// This class describes the common interface of the graph maps
1214    /// (NodeMap, EdgeMap), that is \ref maps-page "maps" which can be used to
1215    /// associate data to graph descriptors (nodes or edges).
1216    template <typename _Graph, typename _Item, typename _Value>
1217    class GraphMap : public ReadWriteMap<_Item, _Value> {
1218    public:
1219
1220      typedef ReadWriteMap<_Item, _Value> Parent;
1221
1222      /// The graph type of the map.
1223      typedef _Graph Graph;
1224      /// The key type of the map.
1225      typedef _Item Key;
1226      /// The value type of the map.
1227      typedef _Value Value;
1228
1229      /// \brief Construct a new map.
1230      ///
1231      /// Construct a new map for the graph.
1232      explicit GraphMap(const Graph&) {}
1233      /// \brief Construct a new map with default value.
1234      ///
1235      /// Construct a new map for the graph and initalise the values.
1236      GraphMap(const Graph&, const Value&) {}
1237      /// \brief Copy constructor.
1238      ///
1239      /// Copy Constructor.
1240      GraphMap(const GraphMap&) : Parent() {}
1241     
1242      /// \brief Assign operator.
1243      ///
1244      /// Assign operator. It does not mofify the underlying graph,
1245      /// it just iterates on the current item set and set the  map
1246      /// with the value returned by the assigned map.
1247      template <typename CMap>
1248      GraphMap& operator=(const CMap&) {
1249        checkConcept<ReadMap<Key, Value>, CMap>();
1250        return *this;
1251      }
1252
1253      template<typename _Map>
1254      struct Constraints {
1255        void constraints() {
1256          checkConcept<ReadWriteMap<Key, Value>, _Map >();
1257          // Construction with a graph parameter
1258          _Map a(g);
1259          // Constructor with a graph and a default value parameter
1260          _Map a2(g,t);
1261          // Copy constructor.
1262          _Map b(c);
1263         
1264          ReadMap<Key, Value> cmap;
1265          b = cmap;
1266
1267          ignore_unused_variable_warning(a2);
1268          ignore_unused_variable_warning(b);
1269        }
1270
1271        const _Map &c;
1272        const Graph &g;
1273        const typename GraphMap::Value &t;
1274      };
1275
1276    };
1277
1278    /// \brief An empty mappable graph class.
1279    ///
1280    /// This class provides beside the core graph features
1281    /// map interface for the graph structure.
1282    /// This concept is part of the Graph concept.
1283    template <typename _Base = BaseGraphComponent>
1284    class MappableGraphComponent : public _Base  {
1285    public:
1286
1287      typedef _Base Base;
1288      typedef typename Base::Node Node;
1289      typedef typename Base::Edge Edge;
1290
1291      typedef MappableGraphComponent Graph;
1292
1293      /// \brief ReadWrite map of the nodes.
1294      ///
1295      /// ReadWrite map of the nodes.
1296      ///
[2181]1297      template <typename _Value>
1298      class NodeMap : public GraphMap<Graph, Node, _Value> {
[2126]1299      private:
1300        NodeMap();
1301      public:
[2181]1302        typedef GraphMap<MappableGraphComponent, Node, _Value> Parent;
[2126]1303
1304        /// \brief Construct a new map.
1305        ///
1306        /// Construct a new map for the graph.
1307        /// \todo call the right parent class constructor
[2181]1308        explicit NodeMap(const MappableGraphComponent& graph)
1309          : Parent(graph) {}
[2126]1310
1311        /// \brief Construct a new map with default value.
1312        ///
1313        /// Construct a new map for the graph and initalise the values.
[2181]1314        NodeMap(const MappableGraphComponent& graph, const _Value& value)
[2126]1315          : Parent(graph, value) {}
1316
1317        /// \brief Copy constructor.
1318        ///
1319        /// Copy Constructor.
1320        NodeMap(const NodeMap& nm) : Parent(nm) {}
1321
1322        /// \brief Assign operator.
1323        ///
1324        /// Assign operator.
1325        template <typename CMap>
1326        NodeMap& operator=(const CMap&) {
[2181]1327          checkConcept<ReadMap<Node, _Value>, CMap>();
[2126]1328          return *this;
1329        }
1330
1331      };
1332
1333      /// \brief ReadWrite map of the edges.
1334      ///
1335      /// ReadWrite map of the edges.
1336      ///
[2181]1337      template <typename _Value>
1338      class EdgeMap : public GraphMap<Graph, Edge, _Value> {
[2126]1339      private:
1340        EdgeMap();
1341      public:
[2181]1342        typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
[2126]1343
1344        /// \brief Construct a new map.
1345        ///
1346        /// Construct a new map for the graph.
1347        /// \todo call the right parent class constructor
[2181]1348        explicit EdgeMap(const MappableGraphComponent& graph)
1349          : Parent(graph) {}
[2126]1350
1351        /// \brief Construct a new map with default value.
1352        ///
1353        /// Construct a new map for the graph and initalise the values.
[2181]1354        EdgeMap(const MappableGraphComponent& graph, const _Value& value)
[2126]1355          : Parent(graph, value) {}
1356
1357        /// \brief Copy constructor.
1358        ///
1359        /// Copy Constructor.
1360        EdgeMap(const EdgeMap& nm) : Parent(nm) {}
1361
1362        /// \brief Assign operator.
1363        ///
1364        /// Assign operator.
1365        template <typename CMap>
1366        EdgeMap& operator=(const CMap&) {
[2181]1367          checkConcept<ReadMap<Edge, _Value>, CMap>();
[2126]1368          return *this;
1369        }
1370
1371      };
1372
1373
1374      template <typename _Graph>
1375      struct Constraints {
1376
1377        struct Dummy {
1378          int value;
1379          Dummy() : value(0) {}
1380          Dummy(int _v) : value(_v) {}
1381        };
1382
1383        void constraints() {
1384          checkConcept<Base, _Graph>();
1385          { // int map test
1386            typedef typename _Graph::template NodeMap<int> IntNodeMap;
1387            checkConcept<GraphMap<_Graph, typename _Graph::Node, int>,
1388              IntNodeMap >();
1389          } { // bool map test
1390            typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
1391            checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
1392              BoolNodeMap >();
1393          } { // Dummy map test
1394            typedef typename _Graph::template NodeMap<Dummy> DummyNodeMap;
1395            checkConcept<GraphMap<_Graph, typename _Graph::Node, Dummy>,
1396              DummyNodeMap >();
1397          }
1398
1399          { // int map test
1400            typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
1401            checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
1402              IntEdgeMap >();
1403          } { // bool map test
1404            typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
1405            checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
1406              BoolEdgeMap >();
1407          } { // Dummy map test
1408            typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
1409            checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
1410              DummyEdgeMap >();
1411          }
1412        }
1413
1414        _Graph& graph;
1415      };
1416    };
1417
1418    /// \brief An empty mappable base graph class.
1419    ///
1420    /// This class provides beside the core graph features
1421    /// map interface for the graph structure.
1422    /// This concept is part of the UGraph concept.
1423    template <typename _Base = BaseUGraphComponent>
1424    class MappableUGraphComponent : public MappableGraphComponent<_Base>  {
1425    public:
1426
1427      typedef _Base Base;
1428      typedef typename Base::UEdge UEdge;
1429
1430      typedef MappableUGraphComponent Graph;
1431
1432      /// \brief ReadWrite map of the uedges.
1433      ///
1434      /// ReadWrite map of the uedges.
1435      ///
[2181]1436      template <typename _Value>
1437      class UEdgeMap : public GraphMap<Graph, UEdge, _Value> { 
[2126]1438      public:
[2181]1439        typedef GraphMap<MappableUGraphComponent, UEdge, _Value> Parent;
[2126]1440
1441        /// \brief Construct a new map.
1442        ///
1443        /// Construct a new map for the graph.
1444        /// \todo call the right parent class constructor
[2181]1445        explicit UEdgeMap(const MappableUGraphComponent& graph)
1446          : Parent(graph) {}
[2126]1447
1448        /// \brief Construct a new map with default value.
1449        ///
1450        /// Construct a new map for the graph and initalise the values.
[2181]1451        UEdgeMap(const MappableUGraphComponent& graph, const _Value& value)
[2126]1452          : Parent(graph, value) {}
1453
1454        /// \brief Copy constructor.
1455        ///
1456        /// Copy Constructor.
1457        UEdgeMap(const UEdgeMap& nm) : Parent(nm) {}
1458
1459        /// \brief Assign operator.
1460        ///
1461        /// Assign operator.
1462        template <typename CMap>
1463        UEdgeMap& operator=(const CMap&) {
[2181]1464          checkConcept<ReadMap<UEdge, _Value>, CMap>();
[2126]1465          return *this;
1466        }
1467
1468      };
1469
1470
1471      template <typename _Graph>
1472      struct Constraints {
1473
1474        struct Dummy {
1475          int value;
1476          Dummy() : value(0) {}
1477          Dummy(int _v) : value(_v) {}
1478        };
1479
1480        void constraints() {
1481          checkConcept<Base, _Graph>();
1482          checkConcept<MappableGraphComponent<Base>, _Graph>();
1483
1484          { // int map test
1485            typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
1486            checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
1487              IntUEdgeMap >();
1488          } { // bool map test
1489            typedef typename _Graph::template UEdgeMap<bool> BoolUEdgeMap;
1490            checkConcept<GraphMap<_Graph, typename _Graph::UEdge, bool>,
1491              BoolUEdgeMap >();
1492          } { // Dummy map test
1493            typedef typename _Graph::template UEdgeMap<Dummy> DummyUEdgeMap;
1494            checkConcept<GraphMap<_Graph, typename _Graph::UEdge, Dummy>,
1495              DummyUEdgeMap >();
1496          }
1497        }
1498
1499        _Graph& graph;
1500      };
1501    };
1502
1503
1504    /// \brief An empty extendable graph class.
1505    ///
1506    /// This class provides beside the core graph features graph
1507    /// extendable interface for the graph structure.  The main
1508    /// difference between the base and this interface is that the
1509    /// graph alterations should handled already on this level.
1510    template <typename _Base = BaseGraphComponent>
1511    class ExtendableGraphComponent : public _Base {
1512    public:
1513
1514      typedef typename _Base::Node Node;
1515      typedef typename _Base::Edge Edge;
1516
1517      /// \brief Adds a new node to the graph.
1518      ///
1519      /// Adds a new node to the graph.
1520      ///
1521      Node addNode() {
1522        return INVALID;
1523      }
1524   
1525      /// \brief Adds a new edge connects the given two nodes.
1526      ///
1527      /// Adds a new edge connects the the given two nodes.
1528      Edge addEdge(const Node&, const Node&) {
1529        return INVALID;
1530      }
1531
1532      template <typename _Graph>
1533      struct Constraints {
1534        void constraints() {
1535          typename _Graph::Node node_a, node_b;
1536          node_a = graph.addNode();
1537          node_b = graph.addNode();
1538          typename _Graph::Edge edge;
1539          edge = graph.addEdge(node_a, node_b);
1540        }
1541
1542        _Graph& graph;
1543      };
1544    };
1545
1546    /// \brief An empty extendable base undirected graph class.
1547    ///
1548    /// This class provides beside the core undirected graph features
1549    /// core undircted graph extend interface for the graph structure.
1550    /// The main difference between the base and this interface is
1551    /// that the graph alterations should handled already on this
1552    /// level.
1553    template <typename _Base = BaseUGraphComponent>
1554    class ExtendableUGraphComponent : public _Base {
1555    public:
1556
1557      typedef typename _Base::Node Node;
1558      typedef typename _Base::UEdge UEdge;
1559
1560      /// \brief Adds a new node to the graph.
1561      ///
1562      /// Adds a new node to the graph.
1563      ///
1564      Node addNode() {
1565        return INVALID;
1566      }
1567   
1568      /// \brief Adds a new edge connects the given two nodes.
1569      ///
1570      /// Adds a new edge connects the the given two nodes.
1571      UEdge addEdge(const Node&, const Node&) {
1572        return INVALID;
1573      }
1574
1575      template <typename _Graph>
1576      struct Constraints {
1577        void constraints() {
1578          typename _Graph::Node node_a, node_b;
1579          node_a = graph.addNode();
1580          node_b = graph.addNode();
1581          typename _Graph::UEdge uedge;
1582          uedge = graph.addUEdge(node_a, node_b);
1583        }
1584
1585        _Graph& graph;
1586      };
1587    };
1588
1589    /// \brief An empty erasable graph class.
1590    /// 
1591    /// This class provides beside the core graph features core erase
1592    /// functions for the graph structure. The main difference between
1593    /// the base and this interface is that the graph alterations
1594    /// should handled already on this level.
1595    template <typename _Base = BaseGraphComponent>
1596    class ErasableGraphComponent : public _Base {
1597    public:
1598
1599      typedef _Base Base;
1600      typedef typename Base::Node Node;
1601      typedef typename Base::Edge Edge;
1602
1603      /// \brief Erase a node from the graph.
1604      ///
1605      /// Erase a node from the graph. This function should
1606      /// erase all edges connecting to the node.
1607      void erase(const Node&) {}   
1608
1609      /// \brief Erase an edge from the graph.
1610      ///
1611      /// Erase an edge from the graph.
1612      ///
1613      void erase(const Edge&) {}
1614
1615      template <typename _Graph>
1616      struct Constraints {
1617        void constraints() {
1618          typename _Graph::Node node;
1619          graph.erase(node);
1620          typename _Graph::Edge edge;
1621          graph.erase(edge);
1622        }
1623
1624        _Graph& graph;
1625      };
1626    };
1627
1628    /// \brief An empty erasable base undirected graph class.
1629    /// 
1630    /// This class provides beside the core undirected graph features
1631    /// core erase functions for the undirceted graph structure. The
1632    /// main difference between the base and this interface is that
1633    /// the graph alterations should handled already on this level.
1634    template <typename _Base = BaseUGraphComponent>
1635    class ErasableUGraphComponent : public _Base {
1636    public:
1637
1638      typedef _Base Base;
1639      typedef typename Base::Node Node;
1640      typedef typename Base::UEdge UEdge;
1641
1642      /// \brief Erase a node from the graph.
1643      ///
1644      /// Erase a node from the graph. This function should erase
1645      /// edges connecting to the node.
1646      void erase(const Node&) {}   
1647
1648      /// \brief Erase an edge from the graph.
1649      ///
1650      /// Erase an edge from the graph.
1651      ///
1652      void erase(const UEdge&) {}
1653
1654      template <typename _Graph>
1655      struct Constraints {
1656        void constraints() {
1657          typename _Graph::Node node;
1658          graph.erase(node);
1659          typename _Graph::Edge edge;
1660          graph.erase(edge);
1661        }
1662
1663        _Graph& graph;
1664      };
1665    };
1666
1667    /// \brief An empty clearable base graph class.
1668    ///
1669    /// This class provides beside the core graph features core clear
1670    /// functions for the graph structure. The main difference between
1671    /// the base and this interface is that the graph alterations
1672    /// should handled already on this level.
1673    template <typename _Base = BaseGraphComponent>
1674    class ClearableGraphComponent : public _Base {
1675    public:
1676
1677      /// \brief Erase all nodes and edges from the graph.
1678      ///
1679      /// Erase all nodes and edges from the graph.
1680      ///
1681      void clear() {}   
1682
1683      template <typename _Graph>
1684      struct Constraints {
1685        void constraints() {
1686          graph.clear();
1687        }
1688
1689        _Graph graph;
1690      };
1691    };
1692
1693    /// \brief An empty clearable base undirected graph class.
1694    ///
1695    /// This class provides beside the core undirected graph features
1696    /// core clear functions for the undirected graph structure. The
1697    /// main difference between the base and this interface is that
1698    /// the graph alterations should handled already on this level.
1699    template <typename _Base = BaseUGraphComponent>
1700    class ClearableUGraphComponent : public _Base {
1701    public:
1702
1703      /// \brief Erase all nodes and undirected edges from the graph.
1704      ///
1705      /// Erase all nodes and undirected edges from the graph.
1706      ///
1707      void clear() {}   
1708
1709      template <typename _Graph>
1710      struct Constraints {
1711        void constraints() {
1712          graph.clear();
1713        }
1714
1715        _Graph graph;
1716      };
1717    };
1718
1719  }
1720
1721}
1722
1723#endif
Note: See TracBrowser for help on using the repository browser.