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