lemon/concepts/graph_components.h
author Alpar Juttner <alpar@cs.elte.hu>
Tue, 01 Nov 2011 13:59:35 +0100
changeset 958 9a716871028e
parent 786 e20173729589
child 976 426a704d7483
child 998 7fdaa05a69a1
permissions -rw-r--r--
Merge bugfix #430
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@877
     5
 * Copyright (C) 2003-2010
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
kpeter@786
    21
///\brief The concepts of graph components.
deba@57
    22
deba@529
    23
#ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H
deba@529
    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@579
    34
    /// \brief Concept class for \c Node, \c Arc and \c Edge types.
deba@57
    35
    ///
kpeter@579
    36
    /// This class describes the concept of \c Node, \c Arc and \c Edge
kpeter@579
    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@579
    40
    /// create graph skeleton classes. The reason for this is that \c Node
alpar@877
    41
    /// and \c Arc (or \c Edge) types should \e not derive from the same
kpeter@579
    42
    /// base class. For \c Node you should instantiate it with character
kpeter@579
    43
    /// \c 'n', for \c Arc with \c 'a' and for \c Edge with \c 'e'.
deba@57
    44
#ifndef DOXYGEN
kpeter@559
    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@579
    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@579
    56
deba@57
    57
      /// \brief Copy constructor.
deba@57
    58
      ///
deba@57
    59
      /// Copy constructor.
kpeter@579
    60
      GraphItem(const GraphItem &) {}
kpeter@579
    61
kpeter@579
    62
      /// \brief Constructor for conversion from \c INVALID.
deba@57
    63
      ///
kpeter@579
    64
      /// Constructor for conversion from \c INVALID.
kpeter@579
    65
      /// It initializes the item to be invalid.
deba@57
    66
      /// \sa Invalid for more details.
deba@57
    67
      GraphItem(Invalid) {}
kpeter@579
    68
kpeter@579
    69
      /// \brief Assignment operator.
deba@57
    70
      ///
kpeter@579
    71
      /// Assignment operator for the item.
kpeter@579
    72
      GraphItem& operator=(const GraphItem&) { return *this; }
kpeter@579
    73
alpar@666
    74
      /// \brief Assignment operator for INVALID.
alpar@666
    75
      ///
alpar@666
    76
      /// This operator makes the item invalid.
alpar@666
    77
      GraphItem& operator=(Invalid) { return *this; }
alpar@666
    78
deba@57
    79
      /// \brief Equality operator.
deba@57
    80
      ///
kpeter@579
    81
      /// Equality operator.
kpeter@579
    82
      bool operator==(const GraphItem&) const { return false; }
kpeter@579
    83
deba@57
    84
      /// \brief Inequality operator.
deba@57
    85
      ///
kpeter@579
    86
      /// Inequality operator.
kpeter@579
    87
      bool operator!=(const GraphItem&) const { return false; }
kpeter@579
    88
kpeter@579
    89
      /// \brief Ordering operator.
deba@57
    90
      ///
kpeter@579
    91
      /// This operator defines an ordering of the items.
alpar@877
    92
      /// It makes possible to use graph item types as key types in
kpeter@579
    93
      /// associative containers (e.g. \c std::map).
deba@57
    94
      ///
kpeter@734
    95
      /// \note This operator only has 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@579
    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@666
   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@579
   121
    /// \brief Base skeleton class for directed graphs.
alpar@209
   122
    ///
kpeter@579
   123
    /// This class describes the base interface of directed graph types.
kpeter@579
   124
    /// All digraph %concepts have to conform to this class.
alpar@877
   125
    /// It just provides types for nodes and arcs and functions
kpeter@579
   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@579
   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@579
   139
      /// This class represents the arcs of the digraph.
kpeter@579
   140
      typedef GraphItem<'a'> Arc;
kpeter@579
   141
kpeter@579
   142
      /// \brief Return the source node of an arc.
deba@57
   143
      ///
kpeter@579
   144
      /// This function returns the source node of an arc.
kpeter@579
   145
      Node source(const Arc&) const { return INVALID; }
deba@57
   146
kpeter@579
   147
      /// \brief Return the target node of an arc.
deba@57
   148
      ///
kpeter@579
   149
      /// This function returns the target node of an arc.
kpeter@579
   150
      Node target(const Arc&) const { return INVALID; }
kpeter@579
   151
kpeter@579
   152
      /// \brief Return the opposite node on the given arc.
deba@57
   153
      ///
kpeter@579
   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@579
   180
    /// \brief Base skeleton class for undirected graphs.
alpar@209
   181
    ///
kpeter@579
   182
    /// This class describes the base interface of undirected graph types.
kpeter@579
   183
    /// All graph %concepts have to conform to this class.
kpeter@579
   184
    /// It extends the interface of \ref BaseDigraphComponent with an
kpeter@579
   185
    /// \c Edge type and functions to get the end nodes of edges,
kpeter@579
   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@617
   189
kpeter@617
   190
      typedef BaseGraphComponent Graph;
kpeter@617
   191
deba@57
   192
      typedef BaseDigraphComponent::Node Node;
deba@57
   193
      typedef BaseDigraphComponent::Arc Arc;
kpeter@579
   194
kpeter@579
   195
      /// \brief Undirected edge class of the graph.
deba@57
   196
      ///
kpeter@579
   197
      /// This class represents the undirected edges of the graph.
kpeter@579
   198
      /// Undirected graphs can be used as directed graphs, each edge is
kpeter@579
   199
      /// represented by two opposite directed arcs.
kpeter@579
   200
      class Edge : public GraphItem<'e'> {
kpeter@579
   201
        typedef GraphItem<'e'> Parent;
kpeter@579
   202
kpeter@617
   203
      public:
deba@57
   204
        /// \brief Default constructor.
alpar@209
   205
        ///
kpeter@579
   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@579
   211
deba@57
   212
        /// \brief Copy constructor.
deba@57
   213
        ///
deba@57
   214
        /// Copy constructor.
kpeter@579
   215
        Edge(const Edge &) : Parent() {}
kpeter@579
   216
kpeter@579
   217
        /// \brief Constructor for conversion from \c INVALID.
deba@57
   218
        ///
kpeter@579
   219
        /// Constructor for conversion from \c INVALID.
kpeter@579
   220
        /// It initializes the item to be invalid.
deba@57
   221
        /// \sa Invalid for more details.
deba@57
   222
        Edge(Invalid) {}
kpeter@579
   223
kpeter@579
   224
        /// \brief Constructor for conversion from an arc.
deba@57
   225
        ///
kpeter@579
   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@666
   230
     };
deba@57
   231
kpeter@579
   232
      /// \brief Return one end node of an edge.
kpeter@579
   233
      ///
kpeter@579
   234
      /// This function returns one end node of an edge.
kpeter@579
   235
      Node u(const Edge&) const { return INVALID; }
kpeter@579
   236
kpeter@579
   237
      /// \brief Return the other end node of an edge.
kpeter@579
   238
      ///
kpeter@579
   239
      /// This function returns the other end node of an edge.
kpeter@579
   240
      Node v(const Edge&) const { return INVALID; }
kpeter@579
   241
kpeter@579
   242
      /// \brief Return a directed arc related to an edge.
kpeter@579
   243
      ///
kpeter@579
   244
      /// This function returns a directed arc from its direction and the
kpeter@579
   245
      /// represented edge.
kpeter@579
   246
      Arc direct(const Edge&, bool) const { return INVALID; }
kpeter@579
   247
kpeter@579
   248
      /// \brief Return a directed arc related to an edge.
kpeter@579
   249
      ///
kpeter@579
   250
      /// This function returns a directed arc from its source node and the
kpeter@579
   251
      /// represented edge.
kpeter@579
   252
      Arc direct(const Edge&, const Node&) const { return INVALID; }
kpeter@579
   253
kpeter@579
   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@579
   261
      /// \brief Return the opposite arc.
deba@57
   262
      ///
kpeter@579
   263
      /// This function returns the opposite arc, i.e. the arc representing
kpeter@579
   264
      /// the same edge and has opposite direction.
kpeter@579
   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@579
   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@579
   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@579
   297
    /// \brief Skeleton class for \e idable directed graphs.
alpar@209
   298
    ///
kpeter@579
   299
    /// This class describes the interface of \e idable directed graphs.
kpeter@579
   300
    /// It extends \ref BaseDigraphComponent with the core ID functions.
kpeter@579
   301
    /// The ids of the items must be unique and immutable.
kpeter@579
   302
    /// This concept is part of the Digraph concept.
kpeter@559
   303
    template <typename BAS = BaseDigraphComponent>
kpeter@559
   304
    class IDableDigraphComponent : public BAS {
deba@57
   305
    public:
deba@57
   306
kpeter@559
   307
      typedef BAS Base;
deba@57
   308
      typedef typename Base::Node Node;
deba@57
   309
      typedef typename Base::Arc Arc;
deba@57
   310
kpeter@579
   311
      /// \brief Return a unique integer id for the given node.
deba@57
   312
      ///
kpeter@579
   313
      /// This function returns a unique integer id for the given node.
kpeter@579
   314
      int id(const Node&) const { return -1; }
kpeter@579
   315
kpeter@579
   316
      /// \brief Return the node by its unique id.
deba@57
   317
      ///
kpeter@579
   318
      /// This function returns the node by its unique id.
kpeter@579
   319
      /// If the digraph does not contain a node with the given id,
kpeter@579
   320
      /// then the result of the function is undefined.
kpeter@579
   321
      Node nodeFromId(int) const { return INVALID; }
deba@57
   322
kpeter@579
   323
      /// \brief Return a unique integer id for the given arc.
deba@57
   324
      ///
kpeter@579
   325
      /// This function returns a unique integer id for the given arc.
kpeter@579
   326
      int id(const Arc&) const { return -1; }
deba@57
   327
kpeter@579
   328
      /// \brief Return the arc by its unique id.
deba@57
   329
      ///
kpeter@579
   330
      /// This function returns the arc by its unique id.
kpeter@579
   331
      /// If the digraph does not contain an arc with the given id,
kpeter@579
   332
      /// then the result of the function is undefined.
kpeter@579
   333
      Arc arcFromId(int) const { return INVALID; }
kpeter@579
   334
kpeter@579
   335
      /// \brief Return an integer greater or equal to the maximum
kpeter@579
   336
      /// node id.
deba@57
   337
      ///
kpeter@579
   338
      /// This function returns an integer greater or equal to the
kpeter@579
   339
      /// maximum node id.
kpeter@579
   340
      int maxNodeId() const { return -1; }
deba@57
   341
kpeter@579
   342
      /// \brief Return an integer greater or equal to the maximum
kpeter@579
   343
      /// arc id.
deba@57
   344
      ///
kpeter@579
   345
      /// This function returns an integer greater or equal to the
kpeter@579
   346
      /// maximum arc id.
kpeter@579
   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@666
   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@666
   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@579
   375
    /// \brief Skeleton class for \e idable undirected graphs.
alpar@209
   376
    ///
kpeter@579
   377
    /// This class describes the interface of \e idable undirected
kpeter@579
   378
    /// graphs. It extends \ref IDableDigraphComponent with the core ID
kpeter@579
   379
    /// functions of undirected graphs.
kpeter@579
   380
    /// The ids of the items must be unique and immutable.
kpeter@579
   381
    /// This concept is part of the Graph concept.
kpeter@559
   382
    template <typename BAS = BaseGraphComponent>
kpeter@559
   383
    class IDableGraphComponent : public IDableDigraphComponent<BAS> {
deba@57
   384
    public:
deba@57
   385
kpeter@559
   386
      typedef BAS Base;
deba@57
   387
      typedef typename Base::Edge Edge;
deba@57
   388
kpeter@559
   389
      using IDableDigraphComponent<Base>::id;
deba@57
   390
kpeter@579
   391
      /// \brief Return a unique integer id for the given edge.
deba@57
   392
      ///
kpeter@579
   393
      /// This function returns a unique integer id for the given edge.
kpeter@579
   394
      int id(const Edge&) const { return -1; }
kpeter@579
   395
kpeter@579
   396
      /// \brief Return the edge by its unique id.
deba@57
   397
      ///
kpeter@579
   398
      /// This function returns the edge by its unique id.
kpeter@579
   399
      /// If the graph does not contain an edge with the given id,
kpeter@579
   400
      /// then the result of the function is undefined.
kpeter@579
   401
      Edge edgeFromId(int) const { return INVALID; }
deba@57
   402
kpeter@579
   403
      /// \brief Return an integer greater or equal to the maximum
kpeter@579
   404
      /// edge id.
deba@57
   405
      ///
kpeter@579
   406
      /// This function returns an integer greater or equal to the
kpeter@579
   407
      /// maximum edge id.
kpeter@579
   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@579
   427
    /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
deba@57
   428
    ///
alpar@877
   429
    /// This class describes the concept of \c NodeIt, \c ArcIt and
kpeter@579
   430
    /// \c EdgeIt subtypes of digraph and graph types.
kpeter@559
   431
    template <typename GR, typename Item>
kpeter@559
   432
    class GraphItemIt : public Item {
deba@57
   433
    public:
deba@57
   434
      /// \brief Default constructor.
deba@57
   435
      ///
kpeter@579
   436
      /// Default constructor.
kpeter@579
   437
      /// \warning The default constructor is not required to set
kpeter@579
   438
      /// the iterator to some well-defined value. So you should consider it
kpeter@579
   439
      /// as uninitialized.
deba@57
   440
      GraphItemIt() {}
kpeter@579
   441
deba@57
   442
      /// \brief Copy constructor.
deba@57
   443
      ///
deba@57
   444
      /// Copy constructor.
kpeter@579
   445
      GraphItemIt(const GraphItemIt& it) : Item(it) {}
kpeter@579
   446
kpeter@579
   447
      /// \brief Constructor that sets the iterator to the first item.
deba@57
   448
      ///
kpeter@579
   449
      /// Constructor that sets the iterator to the first item.
kpeter@579
   450
      explicit GraphItemIt(const GR&) {}
kpeter@579
   451
kpeter@579
   452
      /// \brief Constructor for conversion from \c INVALID.
deba@57
   453
      ///
kpeter@579
   454
      /// Constructor for conversion from \c INVALID.
kpeter@579
   455
      /// It initializes the iterator to be invalid.
deba@57
   456
      /// \sa Invalid for more details.
deba@57
   457
      GraphItemIt(Invalid) {}
kpeter@579
   458
kpeter@579
   459
      /// \brief Assignment operator.
deba@57
   460
      ///
kpeter@579
   461
      /// Assignment operator for the iterator.
kpeter@579
   462
      GraphItemIt& operator=(const GraphItemIt&) { return *this; }
kpeter@579
   463
kpeter@579
   464
      /// \brief Increment the iterator.
deba@57
   465
      ///
kpeter@579
   466
      /// This operator increments the iterator, i.e. assigns it to the
kpeter@579
   467
      /// next item.
deba@57
   468
      GraphItemIt& operator++() { return *this; }
alpar@877
   469
deba@57
   470
      /// \brief Equality operator
alpar@209
   471
      ///
kpeter@579
   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@579
   476
deba@57
   477
      /// \brief Inequality operator
alpar@209
   478
      ///
kpeter@579
   479
      /// Inequality operator.
kpeter@579
   480
      /// Two iterators are equal if and only if they point to the
kpeter@579
   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@579
   487
          checkConcept<GraphItem<>, _GraphItemIt>();
alpar@209
   488
          _GraphItemIt it1(g);
alpar@209
   489
          _GraphItemIt it2;
kpeter@579
   490
          _GraphItemIt it3 = it1;
kpeter@579
   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@559
   497
          Item bi = it1;
alpar@209
   498
          bi = it2;
alpar@209
   499
        }
kpeter@579
   500
        const GR& g;
deba@57
   501
      };
deba@57
   502
    };
deba@57
   503
alpar@877
   504
    /// \brief Concept class for \c InArcIt, \c OutArcIt and
kpeter@579
   505
    /// \c IncEdgeIt types.
deba@57
   506
    ///
alpar@877
   507
    /// This class describes the concept of \c InArcIt, \c OutArcIt
kpeter@579
   508
    /// and \c IncEdgeIt subtypes of digraph and graph types.
kpeter@579
   509
    ///
kpeter@579
   510
    /// \note Since these iterator classes do not inherit from the same
kpeter@579
   511
    /// base class, there is an additional template parameter (selector)
alpar@877
   512
    /// \c sel. For \c InArcIt you should instantiate it with character
kpeter@579
   513
    /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
kpeter@559
   514
    template <typename GR,
kpeter@559
   515
              typename Item = typename GR::Arc,
kpeter@559
   516
              typename Base = typename GR::Node,
kpeter@559
   517
              char sel = '0'>
kpeter@559
   518
    class GraphIncIt : public Item {
deba@57
   519
    public:
deba@57
   520
      /// \brief Default constructor.
deba@57
   521
      ///
kpeter@579
   522
      /// Default constructor.
kpeter@579
   523
      /// \warning The default constructor is not required to set
kpeter@579
   524
      /// the iterator to some well-defined value. So you should consider it
kpeter@579
   525
      /// as uninitialized.
deba@57
   526
      GraphIncIt() {}
kpeter@579
   527
deba@57
   528
      /// \brief Copy constructor.
deba@57
   529
      ///
deba@57
   530
      /// Copy constructor.
kpeter@579
   531
      GraphIncIt(const GraphIncIt& it) : Item(it) {}
kpeter@579
   532
alpar@877
   533
      /// \brief Constructor that sets the iterator to the first
kpeter@579
   534
      /// incoming or outgoing arc.
deba@57
   535
      ///
alpar@877
   536
      /// Constructor that sets the iterator to the first arc
kpeter@579
   537
      /// incoming to or outgoing from the given node.
kpeter@579
   538
      explicit GraphIncIt(const GR&, const Base&) {}
kpeter@579
   539
kpeter@579
   540
      /// \brief Constructor for conversion from \c INVALID.
deba@57
   541
      ///
kpeter@579
   542
      /// Constructor for conversion from \c INVALID.
kpeter@579
   543
      /// It initializes the iterator to be invalid.
deba@57
   544
      /// \sa Invalid for more details.
deba@57
   545
      GraphIncIt(Invalid) {}
kpeter@579
   546
kpeter@579
   547
      /// \brief Assignment operator.
deba@57
   548
      ///
kpeter@579
   549
      /// Assignment operator for the iterator.
kpeter@579
   550
      GraphIncIt& operator=(const GraphIncIt&) { return *this; }
kpeter@579
   551
kpeter@579
   552
      /// \brief Increment the iterator.
deba@57
   553
      ///
kpeter@579
   554
      /// This operator increments the iterator, i.e. assigns it to the
kpeter@579
   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@579
   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@579
   567
      /// Inequality operator.
kpeter@579
   568
      /// Two iterators are equal if and only if they point to the
kpeter@579
   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@559
   575
          checkConcept<GraphItem<sel>, _GraphIncIt>();
alpar@209
   576
          _GraphIncIt it1(graph, node);
alpar@209
   577
          _GraphIncIt it2;
kpeter@579
   578
          _GraphIncIt it3 = it1;
kpeter@579
   579
          _GraphIncIt it4 = INVALID;
deba@57
   580
alpar@209
   581
          it2 = ++it1;
alpar@209
   582
          ++it2 = it1;
alpar@209
   583
          ++(++it1);
kpeter@559
   584
          Item e = it1;
alpar@209
   585
          e = it2;
alpar@209
   586
        }
kpeter@579
   587
        const Base& node;
kpeter@579
   588
        const GR& graph;
deba@57
   589
      };
deba@57
   590
    };
deba@57
   591
kpeter@579
   592
    /// \brief Skeleton class for iterable directed graphs.
deba@57
   593
    ///
kpeter@579
   594
    /// This class describes the interface of iterable directed
kpeter@579
   595
    /// graphs. It extends \ref BaseDigraphComponent with the core
kpeter@579
   596
    /// iterable interface.
deba@57
   597
    /// This concept is part of the Digraph concept.
kpeter@559
   598
    template <typename BAS = BaseDigraphComponent>
kpeter@559
   599
    class IterableDigraphComponent : public BAS {
deba@57
   600
deba@57
   601
    public:
alpar@209
   602
kpeter@559
   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@584
   609
      /// \name Base Iteration
alpar@209
   610
      ///
kpeter@579
   611
      /// This interface provides functions for iteration on digraph items.
deba@57
   612
      ///
alpar@209
   613
      /// @{
deba@57
   614
kpeter@579
   615
      /// \brief Return the first node.
alpar@209
   616
      ///
kpeter@579
   617
      /// This function gives back the first node in the iteration order.
deba@57
   618
      void first(Node&) const {}
deba@57
   619
kpeter@579
   620
      /// \brief Return the next node.
deba@57
   621
      ///
kpeter@579
   622
      /// This function gives back the next node in the iteration order.
deba@57
   623
      void next(Node&) const {}
deba@57
   624
kpeter@579
   625
      /// \brief Return the first arc.
deba@57
   626
      ///
kpeter@579
   627
      /// This function gives back the first arc in the iteration order.
deba@57
   628
      void first(Arc&) const {}
deba@57
   629
kpeter@579
   630
      /// \brief Return the next arc.
deba@57
   631
      ///
kpeter@579
   632
      /// This function gives back the next arc in the iteration order.
deba@57
   633
      void next(Arc&) const {}
deba@57
   634
kpeter@579
   635
      /// \brief Return the first arc incomming to the given node.
deba@57
   636
      ///
kpeter@579
   637
      /// This function gives back the first arc incomming to the
kpeter@579
   638
      /// given node.
deba@57
   639
      void firstIn(Arc&, const Node&) const {}
deba@57
   640
kpeter@579
   641
      /// \brief Return the next arc incomming to the given node.
deba@57
   642
      ///
kpeter@579
   643
      /// This function gives back the next arc incomming to the
kpeter@579
   644
      /// given node.
deba@57
   645
      void nextIn(Arc&) const {}
deba@57
   646
kpeter@579
   647
      /// \brief Return the first arc outgoing form the given node.
kpeter@579
   648
      ///
kpeter@579
   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@579
   653
      /// \brief Return the next arc outgoing form the given node.
deba@57
   654
      ///
kpeter@579
   655
      /// This function gives back the next arc outgoing form the
kpeter@579
   656
      /// given node.
deba@57
   657
      void nextOut(Arc&) const {}
deba@57
   658
deba@57
   659
      /// @}
deba@57
   660
kpeter@584
   661
      /// \name Class Based Iteration
alpar@209
   662
      ///
kpeter@579
   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@579
   673
      /// \brief This iterator goes through each arc.
deba@57
   674
      ///
kpeter@579
   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@579
   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@579
   693
      /// This function gives back the base node of the iterator.
kpeter@579
   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@579
   699
      /// This function gives back the running node of the iterator.
kpeter@579
   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@579
   705
      /// This function gives back the base node of the iterator.
kpeter@579
   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@579
   711
      /// This function gives back the running node of the iterator.
kpeter@579
   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@579
   754
            const typename _Digraph::InArcIt iait(INVALID);
kpeter@579
   755
            const typename _Digraph::OutArcIt oait(INVALID);
kpeter@579
   756
            n = digraph.baseNode(iait);
kpeter@579
   757
            n = digraph.runningNode(iait);
kpeter@579
   758
            n = digraph.baseNode(oait);
kpeter@579
   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@579
   768
    /// \brief Skeleton class for iterable undirected graphs.
deba@57
   769
    ///
kpeter@579
   770
    /// This class describes the interface of iterable undirected
kpeter@579
   771
    /// graphs. It extends \ref IterableDigraphComponent with the core
kpeter@579
   772
    /// iterable interface of undirected graphs.
deba@57
   773
    /// This concept is part of the Graph concept.
kpeter@559
   774
    template <typename BAS = BaseGraphComponent>
kpeter@559
   775
    class IterableGraphComponent : public IterableDigraphComponent<BAS> {
deba@57
   776
    public:
deba@57
   777
kpeter@559
   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@584
   786
      /// \name Base Iteration
alpar@209
   787
      ///
kpeter@579
   788
      /// This interface provides functions for iteration on edges.
kpeter@579
   789
      ///
alpar@209
   790
      /// @{
deba@57
   791
kpeter@559
   792
      using IterableDigraphComponent<Base>::first;
kpeter@559
   793
      using IterableDigraphComponent<Base>::next;
deba@57
   794
kpeter@579
   795
      /// \brief Return the first edge.
deba@57
   796
      ///
kpeter@579
   797
      /// This function gives back the first edge in the iteration order.
deba@57
   798
      void first(Edge&) const {}
deba@57
   799
kpeter@579
   800
      /// \brief Return the next edge.
deba@57
   801
      ///
kpeter@579
   802
      /// This function gives back the next edge in the iteration order.
deba@57
   803
      void next(Edge&) const {}
deba@57
   804
kpeter@579
   805
      /// \brief Return the first edge incident to the given node.
kpeter@579
   806
      ///
alpar@877
   807
      /// This function gives back the first edge incident to the given
kpeter@579
   808
      /// node. The bool parameter gives back the direction for which the
alpar@877
   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
      ///
alpar@877
   816
      /// This function gives back the next edge incident to the given
kpeter@579
   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@559
   820
      using IterableDigraphComponent<Base>::baseNode;
kpeter@559
   821
      using IterableDigraphComponent<Base>::runningNode;
deba@57
   822
deba@57
   823
      /// @}
deba@57
   824
kpeter@584
   825
      /// \name Class Based Iteration
alpar@209
   826
      ///
kpeter@579
   827
      /// This interface provides iterator classes for edges.
deba@57
   828
      ///
deba@57
   829
      /// @{
deba@57
   830
kpeter@579
   831
      /// \brief This iterator goes through each edge.
deba@57
   832
      ///
kpeter@579
   833
      /// This iterator goes through each edge.
deba@57
   834
      typedef GraphItemIt<Graph, Edge> EdgeIt;
kpeter@579
   835
kpeter@579
   836
      /// \brief This iterator goes trough the incident edges of a
deba@57
   837
      /// node.
deba@57
   838
      ///
kpeter@579
   839
      /// This iterator goes trough the incident edges of a certain
deba@57
   840
      /// node of a graph.
kpeter@579
   841
      typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
kpeter@579
   842
deba@57
   843
      /// \brief The base node of the iterator.
deba@57
   844
      ///
kpeter@579
   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@579
   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@579
   879
              typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
alpar@209
   880
deba@57
   881
            typename _Graph::Node n;
kpeter@579
   882
            const typename _Graph::IncEdgeIt ieit(INVALID);
kpeter@579
   883
            n = graph.baseNode(ieit);
kpeter@579
   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@579
   892
    /// \brief Skeleton class for alterable directed graphs.
alpar@209
   893
    ///
kpeter@579
   894
    /// This class describes the interface of alterable directed
kpeter@579
   895
    /// graphs. It extends \ref BaseDigraphComponent with the alteration
kpeter@579
   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@579
   899
    /// alteration occured in the digraph all the observers will be
deba@57
   900
    /// notified about it.
kpeter@559
   901
    template <typename BAS = BaseDigraphComponent>
kpeter@559
   902
    class AlterableDigraphComponent : public BAS {
deba@57
   903
    public:
deba@57
   904
kpeter@559
   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@579
   910
      /// Node alteration notifier class.
alpar@209
   911
      typedef AlterationNotifier<AlterableDigraphComponent, Node>
deba@57
   912
      NodeNotifier;
kpeter@579
   913
      /// Arc alteration notifier class.
alpar@209
   914
      typedef AlterationNotifier<AlterableDigraphComponent, Arc>
deba@57
   915
      ArcNotifier;
alpar@209
   916
kpeter@579
   917
      /// \brief Return the node alteration notifier.
deba@57
   918
      ///
kpeter@579
   919
      /// This function gives back the node alteration notifier.
deba@57
   920
      NodeNotifier& notifier(Node) const {
kpeter@579
   921
         return NodeNotifier();
deba@57
   922
      }
alpar@209
   923
kpeter@579
   924
      /// \brief Return the arc alteration notifier.
deba@57
   925
      ///
kpeter@579
   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@579
   949
    /// \brief Skeleton class for alterable undirected graphs.
alpar@209
   950
    ///
kpeter@579
   951
    /// This class describes the interface of alterable undirected
kpeter@579
   952
    /// graphs. It extends \ref AlterableDigraphComponent with the alteration
kpeter@579
   953
    /// notifier interface of undirected graphs. It implements
kpeter@579
   954
    /// an observer-notifier pattern for the edges. More
deba@57
   955
    /// obsevers can be registered into the notifier and whenever an
kpeter@579
   956
    /// alteration occured in the graph all the observers will be
deba@57
   957
    /// notified about it.
kpeter@559
   958
    template <typename BAS = BaseGraphComponent>
kpeter@559
   959
    class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
deba@57
   960
    public:
deba@57
   961
kpeter@559
   962
      typedef BAS Base;
deba@57
   963
      typedef typename Base::Edge Edge;
deba@57
   964
deba@57
   965
kpeter@579
   966
      /// Edge alteration notifier class.
alpar@209
   967
      typedef AlterationNotifier<AlterableGraphComponent, Edge>
deba@57
   968
      EdgeNotifier;
alpar@209
   969
kpeter@579
   970
      /// \brief Return the edge alteration notifier.
deba@57
   971
      ///
kpeter@579
   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@579
   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@579
   990
    /// \brief Concept class for standard graph maps.
alpar@209
   991
    ///
kpeter@579
   992
    /// This class describes the concept of standard graph maps, i.e.
alpar@877
   993
    /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
kpeter@579
   994
    /// graph types, which can be used for associating data to graph items.
kpeter@580
   995
    /// The standard graph maps must conform to the ReferenceMap concept.
kpeter@559
   996
    template <typename GR, typename K, typename V>
kpeter@580
   997
    class GraphMap : public ReferenceMap<K, V, V&, const V&> {
kpeter@617
   998
      typedef ReferenceMap<K, V, V&, const V&> Parent;
kpeter@617
   999
deba@57
  1000
    public:
deba@57
  1001
deba@57
  1002
      /// The key type of the map.
kpeter@559
  1003
      typedef K Key;
deba@57
  1004
      /// The value type of the map.
kpeter@559
  1005
      typedef V Value;
kpeter@580
  1006
      /// The reference type of the map.
kpeter@580
  1007
      typedef Value& Reference;
kpeter@580
  1008
      /// The const reference type of the map.
kpeter@580
  1009
      typedef const Value& ConstReference;
kpeter@580
  1010
kpeter@580
  1011
      // The reference map tag.
kpeter@580
  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@617
  1017
      explicit GraphMap(const GR&) {}
deba@57
  1018
      /// \brief Construct a new map with default value.
deba@57
  1019
      ///
kpeter@579
  1020
      /// Construct a new map for the graph and initalize the values.
kpeter@617
  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@579
  1029
      /// \brief Assignment operator.
deba@57
  1030
      ///
kpeter@579
  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@580
  1044
          checkConcept
kpeter@580
  1045
            <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
kpeter@579
  1046
          _Map m1(g);
kpeter@579
  1047
          _Map m2(g,t);
alpar@877
  1048
kpeter@579
  1049
          // Copy constructor
kpeter@579
  1050
          // _Map m3(m);
alpar@209
  1051
kpeter@579
  1052
          // Assignment operator
kpeter@263
  1053
          // ReadMap<Key, Value> cmap;
kpeter@579
  1054
          // m3 = cmap;
deba@57
  1055
kpeter@579
  1056
          ignore_unused_variable_warning(m1);
kpeter@579
  1057
          ignore_unused_variable_warning(m2);
kpeter@579
  1058
          // ignore_unused_variable_warning(m3);
alpar@209
  1059
        }
deba@57
  1060
kpeter@579
  1061
        const _Map &m;
kpeter@617
  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@579
  1068
    /// \brief Skeleton class for mappable directed graphs.
deba@57
  1069
    ///
kpeter@579
  1070
    /// This class describes the interface of mappable directed graphs.
alpar@877
  1071
    /// It extends \ref BaseDigraphComponent with the standard digraph
kpeter@579
  1072
    /// map classes, namely \c NodeMap and \c ArcMap.
deba@57
  1073
    /// This concept is part of the Digraph concept.
kpeter@559
  1074
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  1075
    class MappableDigraphComponent : public BAS  {
deba@57
  1076
    public:
deba@57
  1077
kpeter@559
  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@579
  1084
      /// \brief Standard graph map for the nodes.
deba@57
  1085
      ///
kpeter@579
  1086
      /// Standard graph map for the nodes.
kpeter@580
  1087
      /// It conforms to the ReferenceMap concept.
kpeter@559
  1088
      template <typename V>
kpeter@579
  1089
      class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
kpeter@559
  1090
        typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
deba@57
  1091
kpeter@617
  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@579
  1101
        /// Construct a new map for the digraph and initalize the values.
kpeter@559
  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@579
  1111
        /// \brief Assignment operator.
alpar@209
  1112
        ///
kpeter@579
  1113
        /// Assignment operator.
deba@57
  1114
        template <typename CMap>
alpar@209
  1115
        NodeMap& operator=(const CMap&) {
kpeter@559
  1116
          checkConcept<ReadMap<Node, V>, CMap>();
deba@57
  1117
          return *this;
deba@57
  1118
        }
deba@57
  1119
deba@57
  1120
      };
deba@57
  1121
kpeter@579
  1122
      /// \brief Standard graph map for the arcs.
deba@57
  1123
      ///
kpeter@579
  1124
      /// Standard graph map for the arcs.
kpeter@580
  1125
      /// It conforms to the ReferenceMap concept.
kpeter@559
  1126
      template <typename V>
kpeter@579
  1127
      class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
kpeter@559
  1128
        typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
deba@57
  1129
kpeter@617
  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@579
  1139
        /// Construct a new map for the digraph and initalize the values.
kpeter@559
  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@579
  1149
        /// \brief Assignment operator.
alpar@209
  1150
        ///
kpeter@579
  1151
        /// Assignment operator.
deba@57
  1152
        template <typename CMap>
alpar@209
  1153
        ArcMap& operator=(const CMap&) {
kpeter@559
  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@579
  1201
        const _Digraph& digraph;
deba@57
  1202
      };
deba@57
  1203
    };
deba@57
  1204
kpeter@579
  1205
    /// \brief Skeleton class for mappable undirected graphs.
deba@57
  1206
    ///
kpeter@579
  1207
    /// This class describes the interface of mappable undirected graphs.
alpar@877
  1208
    /// It extends \ref MappableDigraphComponent with the standard graph
kpeter@579
  1209
    /// map class for edges (\c EdgeMap).
deba@57
  1210
    /// This concept is part of the Graph concept.
kpeter@559
  1211
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1212
    class MappableGraphComponent : public MappableDigraphComponent<BAS>  {
deba@57
  1213
    public:
deba@57
  1214
kpeter@559
  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@579
  1220
      /// \brief Standard graph map for the edges.
deba@57
  1221
      ///
kpeter@579
  1222
      /// Standard graph map for the edges.
kpeter@580
  1223
      /// It conforms to the ReferenceMap concept.
kpeter@559
  1224
      template <typename V>
kpeter@579
  1225
      class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
kpeter@559
  1226
        typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
deba@57
  1227
kpeter@617
  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@579
  1237
        /// Construct a new map for the graph and initalize the values.
kpeter@559
  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@579
  1247
        /// \brief Assignment operator.
alpar@209
  1248
        ///
kpeter@579
  1249
        /// Assignment operator.
deba@57
  1250
        template <typename CMap>
alpar@209
  1251
        EdgeMap& operator=(const CMap&) {
kpeter@559
  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@579
  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@579
  1286
        const _Graph& graph;
deba@57
  1287
      };
deba@57
  1288
    };
deba@57
  1289
kpeter@579
  1290
    /// \brief Skeleton class for extendable directed graphs.
deba@57
  1291
    ///
kpeter@579
  1292
    /// This class describes the interface of extendable directed graphs.
alpar@877
  1293
    /// It extends \ref BaseDigraphComponent with functions for adding
kpeter@579
  1294
    /// nodes and arcs to the digraph.
kpeter@579
  1295
    /// This concept requires \ref AlterableDigraphComponent.
kpeter@559
  1296
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  1297
    class ExtendableDigraphComponent : public BAS {
deba@57
  1298
    public:
kpeter@559
  1299
      typedef BAS Base;
deba@57
  1300
kpeter@559
  1301
      typedef typename Base::Node Node;
kpeter@559
  1302
      typedef typename Base::Arc Arc;
deba@57
  1303
kpeter@579
  1304
      /// \brief Add a new node to the digraph.
deba@57
  1305
      ///
kpeter@579
  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@579
  1311
      /// \brief Add a new arc connecting the given two nodes.
deba@57
  1312
      ///
kpeter@579
  1313
      /// This function adds a new arc connecting the given two nodes
kpeter@579
  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@579
  1334
    /// \brief Skeleton class for extendable undirected graphs.
deba@57
  1335
    ///
kpeter@579
  1336
    /// This class describes the interface of extendable undirected graphs.
alpar@877
  1337
    /// It extends \ref BaseGraphComponent with functions for adding
kpeter@579
  1338
    /// nodes and edges to the graph.
kpeter@579
  1339
    /// This concept requires \ref AlterableGraphComponent.
kpeter@559
  1340
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1341
    class ExtendableGraphComponent : public BAS {
deba@57
  1342
    public:
deba@57
  1343
kpeter@559
  1344
      typedef BAS Base;
kpeter@559
  1345
      typedef typename Base::Node Node;
kpeter@559
  1346
      typedef typename Base::Edge Edge;
deba@57
  1347
kpeter@579
  1348
      /// \brief Add a new node to the digraph.
deba@57
  1349
      ///
kpeter@579
  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@579
  1355
      /// \brief Add a new edge connecting the given two nodes.
deba@57
  1356
      ///
kpeter@579
  1357
      /// This function adds a new edge connecting the given two nodes
kpeter@579
  1358
      /// of the graph.
kpeter@579
  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@579
  1378
    /// \brief Skeleton class for erasable directed graphs.
alpar@209
  1379
    ///
kpeter@579
  1380
    /// This class describes the interface of erasable directed graphs.
alpar@877
  1381
    /// It extends \ref BaseDigraphComponent with functions for removing
kpeter@579
  1382
    /// nodes and arcs from the digraph.
kpeter@579
  1383
    /// This concept requires \ref AlterableDigraphComponent.
kpeter@559
  1384
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  1385
    class ErasableDigraphComponent : public BAS {
deba@57
  1386
    public:
deba@57
  1387
kpeter@559
  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
      ///
alpar@877
  1394
      /// This function erases the given node from the digraph and all arcs
kpeter@579
  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@579
  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@579
  1407
          const typename _Digraph::Node node(INVALID);
alpar@209
  1408
          digraph.erase(node);
kpeter@579
  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@579
  1417
    /// \brief Skeleton class for erasable undirected graphs.
alpar@209
  1418
    ///
kpeter@579
  1419
    /// This class describes the interface of erasable undirected graphs.
alpar@877
  1420
    /// It extends \ref BaseGraphComponent with functions for removing
kpeter@579
  1421
    /// nodes and edges from the graph.
kpeter@579
  1422
    /// This concept requires \ref AlterableGraphComponent.
kpeter@559
  1423
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1424
    class ErasableGraphComponent : public BAS {
deba@57
  1425
    public:
deba@57
  1426
kpeter@559
  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@579
  1433
      /// This function erases the given node from the graph and all edges
kpeter@579
  1434
      /// connected to the node.
alpar@209
  1435
      void erase(const Node&) {}
deba@57
  1436
kpeter@579
  1437
      /// \brief Erase an edge from the digraph.
deba@57
  1438
      ///
kpeter@579
  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@579
  1446
          const typename _Graph::Node node(INVALID);
alpar@209
  1447
          graph.erase(node);
kpeter@579
  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@579
  1456
    /// \brief Skeleton class for clearable directed graphs.
deba@57
  1457
    ///
kpeter@579
  1458
    /// This class describes the interface of clearable directed graphs.
kpeter@579
  1459
    /// It extends \ref BaseDigraphComponent with a function for clearing
kpeter@579
  1460
    /// the digraph.
kpeter@579
  1461
    /// This concept requires \ref AlterableDigraphComponent.
kpeter@559
  1462
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  1463
    class ClearableDigraphComponent : public BAS {
deba@57
  1464
    public:
deba@57
  1465
kpeter@559
  1466
      typedef BAS Base;
deba@57
  1467
deba@57
  1468
      /// \brief Erase all nodes and arcs from the digraph.
deba@57
  1469
      ///
kpeter@579
  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@579
  1480
        _Digraph& digraph;
deba@57
  1481
      };
deba@57
  1482
    };
deba@57
  1483
kpeter@579
  1484
    /// \brief Skeleton class for clearable undirected graphs.
deba@57
  1485
    ///
kpeter@579
  1486
    /// This class describes the interface of clearable undirected graphs.
kpeter@579
  1487
    /// It extends \ref BaseGraphComponent with a function for clearing
kpeter@579
  1488
    /// the graph.
kpeter@579
  1489
    /// This concept requires \ref AlterableGraphComponent.
kpeter@559
  1490
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1491
    class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {
deba@57
  1492
    public:
deba@57
  1493
kpeter@559
  1494
      typedef BAS Base;
deba@57
  1495
kpeter@579
  1496
      /// \brief Erase all nodes and edges from the graph.
kpeter@579
  1497
      ///
kpeter@579
  1498
      /// This function erases all nodes and edges from the graph.
kpeter@579
  1499
      void clear() {}
kpeter@579
  1500
deba@57
  1501
      template <typename _Graph>
deba@57
  1502
      struct Constraints {
alpar@209
  1503
        void constraints() {
kpeter@579
  1504
          checkConcept<Base, _Graph>();
kpeter@579
  1505
          graph.clear();
alpar@209
  1506
        }
deba@57
  1507
kpeter@579
  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