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