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