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