lemon/concepts/graph_components.h
author Peter Kovacs <kpeter@inf.elte.hu>
Fri, 17 Apr 2009 09:54:14 +0200
changeset 585 7ac52d6a268e
parent 572 2313edd0db0b
child 609 4137ef9aacc6
permissions -rw-r--r--
Extend and modify the interface of matching algorithms (#265)

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