COIN-OR::LEMON - Graph Library

source: lemon/lemon/concepts/graph_components.h @ 1171:7e368d9b67f7

Last change on this file since 1171:7e368d9b67f7 was 1171:7e368d9b67f7, checked in by Alpar Juttner <alpar@…>, 11 years ago

Avoid GCC 4.7 compiler warnings (#453)

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