lemon/concepts/graph_components.h
author Alpar Juttner <alpar@cs.elte.hu>
Tue, 08 Apr 2014 17:13:55 +0200
changeset 1110 489e243cfcb7
parent 1087 dd1443e4a34c
child 1197 f179aa1045a4
permissions -rw-r--r--
Merge bugfix #480
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@1092
     5
 * Copyright (C) 2003-2013
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@1083
   111
          ::lemon::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.
alpar@877
   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);
alpar@1083
   292
            ::lemon::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
deba@1018
   302
    /// \brief Base skeleton class for undirected bipartite graphs.
deba@1018
   303
    ///
deba@1018
   304
    /// This class describes the base interface of undirected
deba@1018
   305
    /// bipartite graph types.  All bipartite graph %concepts have to
deba@1018
   306
    /// conform to this class.  It extends the interface of \ref
deba@1018
   307
    /// BaseGraphComponent with an \c Edge type and functions to get
deba@1018
   308
    /// the end nodes of edges, to convert from arcs to edges and to
deba@1018
   309
    /// get both direction of edges.
deba@1018
   310
    class BaseBpGraphComponent : public BaseGraphComponent {
deba@1018
   311
    public:
deba@1018
   312
deba@1018
   313
      typedef BaseBpGraphComponent BpGraph;
deba@1018
   314
deba@1018
   315
      typedef BaseDigraphComponent::Node Node;
deba@1018
   316
      typedef BaseDigraphComponent::Arc Arc;
deba@1018
   317
deba@1018
   318
      /// \brief Class to represent red nodes.
deba@1018
   319
      ///
deba@1025
   320
      /// This class represents the red nodes of the graph. The red
deba@1028
   321
      /// nodes can also be used as normal nodes.
deba@1018
   322
      class RedNode : public Node {
deba@1018
   323
        typedef Node Parent;
deba@1018
   324
deba@1018
   325
      public:
deba@1018
   326
        /// \brief Default constructor.
deba@1018
   327
        ///
deba@1018
   328
        /// Default constructor.
deba@1018
   329
        /// \warning The default constructor is not required to set
deba@1018
   330
        /// the item to some well-defined value. So you should consider it
deba@1018
   331
        /// as uninitialized.
deba@1018
   332
        RedNode() {}
deba@1018
   333
deba@1018
   334
        /// \brief Copy constructor.
deba@1018
   335
        ///
deba@1018
   336
        /// Copy constructor.
deba@1018
   337
        RedNode(const RedNode &) : Parent() {}
deba@1018
   338
deba@1018
   339
        /// \brief Constructor for conversion from \c INVALID.
deba@1018
   340
        ///
deba@1018
   341
        /// Constructor for conversion from \c INVALID.
deba@1018
   342
        /// It initializes the item to be invalid.
deba@1018
   343
        /// \sa Invalid for more details.
deba@1018
   344
        RedNode(Invalid) {}
deba@1018
   345
      };
deba@1018
   346
deba@1018
   347
      /// \brief Class to represent blue nodes.
deba@1018
   348
      ///
deba@1025
   349
      /// This class represents the blue nodes of the graph. The blue
deba@1028
   350
      /// nodes can also be used as normal nodes.
deba@1018
   351
      class BlueNode : public Node {
deba@1018
   352
        typedef Node Parent;
deba@1018
   353
deba@1018
   354
      public:
deba@1018
   355
        /// \brief Default constructor.
deba@1018
   356
        ///
deba@1018
   357
        /// Default constructor.
deba@1018
   358
        /// \warning The default constructor is not required to set
deba@1018
   359
        /// the item to some well-defined value. So you should consider it
deba@1018
   360
        /// as uninitialized.
deba@1018
   361
        BlueNode() {}
deba@1018
   362
deba@1018
   363
        /// \brief Copy constructor.
deba@1018
   364
        ///
deba@1018
   365
        /// Copy constructor.
deba@1018
   366
        BlueNode(const BlueNode &) : Parent() {}
deba@1018
   367
deba@1018
   368
        /// \brief Constructor for conversion from \c INVALID.
deba@1018
   369
        ///
deba@1018
   370
        /// Constructor for conversion from \c INVALID.
deba@1018
   371
        /// It initializes the item to be invalid.
deba@1018
   372
        /// \sa Invalid for more details.
deba@1018
   373
        BlueNode(Invalid) {}
deba@1018
   374
deba@1018
   375
        /// \brief Constructor for conversion from a node.
deba@1018
   376
        ///
deba@1018
   377
        /// Constructor for conversion from a node. The conversion can
deba@1018
   378
        /// be invalid, since the Node can be member of the red
deba@1018
   379
        /// set.
deba@1018
   380
        BlueNode(const Node&) {}
deba@1018
   381
      };
deba@1018
   382
deba@1018
   383
      /// \brief Gives back %true for red nodes.
deba@1018
   384
      ///
deba@1018
   385
      /// Gives back %true for red nodes.
deba@1018
   386
      bool red(const Node&) const { return true; }
deba@1018
   387
deba@1018
   388
      /// \brief Gives back %true for blue nodes.
deba@1018
   389
      ///
deba@1018
   390
      /// Gives back %true for blue nodes.
deba@1018
   391
      bool blue(const Node&) const { return true; }
deba@1018
   392
deba@1018
   393
      /// \brief Gives back the red end node of the edge.
alpar@1092
   394
      ///
deba@1018
   395
      /// Gives back the red end node of the edge.
deba@1025
   396
      RedNode redNode(const Edge&) const { return RedNode(); }
deba@1018
   397
deba@1018
   398
      /// \brief Gives back the blue end node of the edge.
alpar@1092
   399
      ///
deba@1018
   400
      /// Gives back the blue end node of the edge.
deba@1025
   401
      BlueNode blueNode(const Edge&) const { return BlueNode(); }
deba@1025
   402
deba@1025
   403
      /// \brief Converts the node to red node object.
deba@1025
   404
      ///
deba@1028
   405
      /// This function converts unsafely the node to red node
deba@1025
   406
      /// object. It should be called only if the node is from the red
deba@1025
   407
      /// partition or INVALID.
deba@1025
   408
      RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); }
deba@1025
   409
deba@1025
   410
      /// \brief Converts the node to blue node object.
deba@1025
   411
      ///
deba@1028
   412
      /// This function converts unsafely the node to blue node
deba@1025
   413
      /// object. It should be called only if the node is from the red
deba@1025
   414
      /// partition or INVALID.
deba@1025
   415
      BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); }
deba@1025
   416
deba@1025
   417
      /// \brief Converts the node to red node object.
deba@1025
   418
      ///
deba@1028
   419
      /// This function converts safely the node to red node
deba@1025
   420
      /// object. If the node is not from the red partition, then it
deba@1025
   421
      /// returns INVALID.
deba@1025
   422
      RedNode asRedNode(const Node&) const { return RedNode(); }
deba@1025
   423
deba@1025
   424
      /// \brief Converts the node to blue node object.
deba@1025
   425
      ///
deba@1028
   426
      /// This function converts unsafely the node to blue node
deba@1025
   427
      /// object. If the node is not from the blue partition, then it
deba@1025
   428
      /// returns INVALID.
deba@1025
   429
      BlueNode asBlueNode(const Node&) const { return BlueNode(); }
deba@1025
   430
deba@1018
   431
      template <typename _BpGraph>
deba@1018
   432
      struct Constraints {
deba@1018
   433
        typedef typename _BpGraph::Node Node;
deba@1018
   434
        typedef typename _BpGraph::RedNode RedNode;
deba@1018
   435
        typedef typename _BpGraph::BlueNode BlueNode;
deba@1018
   436
        typedef typename _BpGraph::Arc Arc;
deba@1018
   437
        typedef typename _BpGraph::Edge Edge;
deba@1018
   438
deba@1018
   439
        void constraints() {
deba@1018
   440
          checkConcept<BaseGraphComponent, _BpGraph>();
deba@1018
   441
          checkConcept<GraphItem<'n'>, RedNode>();
deba@1018
   442
          checkConcept<GraphItem<'n'>, BlueNode>();
deba@1018
   443
          {
deba@1018
   444
            Node n;
deba@1025
   445
            RedNode rn;
deba@1025
   446
            BlueNode bn;
deba@1025
   447
            Node rnan = rn;
deba@1025
   448
            Node bnan = bn;
deba@1018
   449
            Edge e;
deba@1018
   450
            bool b;
deba@1025
   451
            b = bpgraph.red(rnan);
deba@1025
   452
            b = bpgraph.blue(bnan);
deba@1025
   453
            rn = bpgraph.redNode(e);
deba@1025
   454
            bn = bpgraph.blueNode(e);
deba@1025
   455
            rn = bpgraph.asRedNodeUnsafe(rnan);
deba@1025
   456
            bn = bpgraph.asBlueNodeUnsafe(bnan);
deba@1025
   457
            rn = bpgraph.asRedNode(rnan);
deba@1025
   458
            bn = bpgraph.asBlueNode(bnan);
alpar@1087
   459
            ::lemon::ignore_unused_variable_warning(b);
deba@1018
   460
          }
deba@1018
   461
        }
deba@1018
   462
deba@1018
   463
        const _BpGraph& bpgraph;
deba@1018
   464
      };
deba@1018
   465
deba@1018
   466
    };
deba@1018
   467
kpeter@579
   468
    /// \brief Skeleton class for \e idable directed graphs.
alpar@209
   469
    ///
kpeter@579
   470
    /// This class describes the interface of \e idable directed graphs.
kpeter@579
   471
    /// It extends \ref BaseDigraphComponent with the core ID functions.
kpeter@579
   472
    /// The ids of the items must be unique and immutable.
kpeter@579
   473
    /// This concept is part of the Digraph concept.
kpeter@559
   474
    template <typename BAS = BaseDigraphComponent>
kpeter@559
   475
    class IDableDigraphComponent : public BAS {
deba@57
   476
    public:
deba@57
   477
kpeter@559
   478
      typedef BAS Base;
deba@57
   479
      typedef typename Base::Node Node;
deba@57
   480
      typedef typename Base::Arc Arc;
deba@57
   481
kpeter@579
   482
      /// \brief Return a unique integer id for the given node.
deba@57
   483
      ///
kpeter@579
   484
      /// This function returns a unique integer id for the given node.
kpeter@579
   485
      int id(const Node&) const { return -1; }
kpeter@579
   486
kpeter@579
   487
      /// \brief Return the node by its unique id.
deba@57
   488
      ///
kpeter@579
   489
      /// This function returns the node by its unique id.
kpeter@579
   490
      /// If the digraph does not contain a node with the given id,
kpeter@579
   491
      /// then the result of the function is undefined.
kpeter@579
   492
      Node nodeFromId(int) const { return INVALID; }
deba@57
   493
kpeter@579
   494
      /// \brief Return a unique integer id for the given arc.
deba@57
   495
      ///
kpeter@579
   496
      /// This function returns a unique integer id for the given arc.
kpeter@579
   497
      int id(const Arc&) const { return -1; }
deba@57
   498
kpeter@579
   499
      /// \brief Return the arc by its unique id.
deba@57
   500
      ///
kpeter@579
   501
      /// This function returns the arc by its unique id.
kpeter@579
   502
      /// If the digraph does not contain an arc with the given id,
kpeter@579
   503
      /// then the result of the function is undefined.
kpeter@579
   504
      Arc arcFromId(int) const { return INVALID; }
kpeter@579
   505
kpeter@579
   506
      /// \brief Return an integer greater or equal to the maximum
kpeter@579
   507
      /// node id.
deba@57
   508
      ///
kpeter@579
   509
      /// This function returns an integer greater or equal to the
kpeter@579
   510
      /// maximum node id.
kpeter@579
   511
      int maxNodeId() const { return -1; }
deba@57
   512
kpeter@579
   513
      /// \brief Return an integer greater or equal to the maximum
kpeter@579
   514
      /// arc id.
deba@57
   515
      ///
kpeter@579
   516
      /// This function returns an integer greater or equal to the
kpeter@579
   517
      /// maximum arc id.
kpeter@579
   518
      int maxArcId() const { return -1; }
deba@57
   519
deba@57
   520
      template <typename _Digraph>
deba@57
   521
      struct Constraints {
deba@57
   522
alpar@209
   523
        void constraints() {
alpar@209
   524
          checkConcept<Base, _Digraph >();
alpar@209
   525
          typename _Digraph::Node node;
alpar@666
   526
          node=INVALID;
alpar@209
   527
          int nid = digraph.id(node);
alpar@209
   528
          nid = digraph.id(node);
alpar@209
   529
          node = digraph.nodeFromId(nid);
alpar@209
   530
          typename _Digraph::Arc arc;
alpar@666
   531
          arc=INVALID;
alpar@209
   532
          int eid = digraph.id(arc);
alpar@209
   533
          eid = digraph.id(arc);
alpar@209
   534
          arc = digraph.arcFromId(eid);
deba@57
   535
alpar@209
   536
          nid = digraph.maxNodeId();
alpar@1083
   537
          ::lemon::ignore_unused_variable_warning(nid);
alpar@209
   538
          eid = digraph.maxArcId();
alpar@1083
   539
          ::lemon::ignore_unused_variable_warning(eid);
alpar@209
   540
        }
deba@57
   541
alpar@209
   542
        const _Digraph& digraph;
alpar@975
   543
        Constraints() {}
deba@57
   544
      };
deba@57
   545
    };
deba@57
   546
kpeter@579
   547
    /// \brief Skeleton class for \e idable undirected graphs.
alpar@209
   548
    ///
kpeter@579
   549
    /// This class describes the interface of \e idable undirected
kpeter@579
   550
    /// graphs. It extends \ref IDableDigraphComponent with the core ID
kpeter@579
   551
    /// functions of undirected graphs.
kpeter@579
   552
    /// The ids of the items must be unique and immutable.
kpeter@579
   553
    /// This concept is part of the Graph concept.
kpeter@559
   554
    template <typename BAS = BaseGraphComponent>
kpeter@559
   555
    class IDableGraphComponent : public IDableDigraphComponent<BAS> {
deba@57
   556
    public:
deba@57
   557
kpeter@559
   558
      typedef BAS Base;
deba@57
   559
      typedef typename Base::Edge Edge;
deba@57
   560
kpeter@559
   561
      using IDableDigraphComponent<Base>::id;
deba@57
   562
kpeter@579
   563
      /// \brief Return a unique integer id for the given edge.
deba@57
   564
      ///
kpeter@579
   565
      /// This function returns a unique integer id for the given edge.
kpeter@579
   566
      int id(const Edge&) const { return -1; }
kpeter@579
   567
kpeter@579
   568
      /// \brief Return the edge by its unique id.
deba@57
   569
      ///
kpeter@579
   570
      /// This function returns the edge by its unique id.
kpeter@579
   571
      /// If the graph does not contain an edge with the given id,
kpeter@579
   572
      /// then the result of the function is undefined.
kpeter@579
   573
      Edge edgeFromId(int) const { return INVALID; }
deba@57
   574
kpeter@579
   575
      /// \brief Return an integer greater or equal to the maximum
kpeter@579
   576
      /// edge id.
deba@57
   577
      ///
kpeter@579
   578
      /// This function returns an integer greater or equal to the
kpeter@579
   579
      /// maximum edge id.
kpeter@579
   580
      int maxEdgeId() const { return -1; }
deba@57
   581
deba@57
   582
      template <typename _Graph>
deba@57
   583
      struct Constraints {
deba@57
   584
alpar@209
   585
        void constraints() {
alpar@209
   586
          checkConcept<IDableDigraphComponent<Base>, _Graph >();
alpar@209
   587
          typename _Graph::Edge edge;
alpar@209
   588
          int ueid = graph.id(edge);
alpar@209
   589
          ueid = graph.id(edge);
alpar@209
   590
          edge = graph.edgeFromId(ueid);
alpar@209
   591
          ueid = graph.maxEdgeId();
alpar@1083
   592
          ::lemon::ignore_unused_variable_warning(ueid);
alpar@209
   593
        }
deba@57
   594
alpar@209
   595
        const _Graph& graph;
alpar@975
   596
        Constraints() {}
deba@57
   597
      };
deba@57
   598
    };
deba@57
   599
deba@1018
   600
    /// \brief Skeleton class for \e idable undirected bipartite graphs.
deba@1018
   601
    ///
deba@1018
   602
    /// This class describes the interface of \e idable undirected
deba@1018
   603
    /// bipartite graphs. It extends \ref IDableGraphComponent with
deba@1018
   604
    /// the core ID functions of undirected bipartite graphs. Beside
deba@1018
   605
    /// the regular node ids, this class also provides ids within the
deba@1018
   606
    /// the red and blue sets of the nodes. This concept is part of
deba@1018
   607
    /// the BpGraph concept.
deba@1018
   608
    template <typename BAS = BaseBpGraphComponent>
deba@1018
   609
    class IDableBpGraphComponent : public IDableGraphComponent<BAS> {
deba@1018
   610
    public:
deba@1018
   611
deba@1018
   612
      typedef BAS Base;
deba@1018
   613
      typedef IDableGraphComponent<BAS> Parent;
deba@1018
   614
      typedef typename Base::Node Node;
deba@1018
   615
      typedef typename Base::RedNode RedNode;
deba@1018
   616
      typedef typename Base::BlueNode BlueNode;
deba@1018
   617
deba@1018
   618
      using Parent::id;
deba@1018
   619
deba@1018
   620
      /// \brief Return a unique integer id for the given node in the red set.
deba@1018
   621
      ///
deba@1018
   622
      /// Return a unique integer id for the given node in the red set.
deba@1018
   623
      int id(const RedNode&) const { return -1; }
deba@1018
   624
deba@1018
   625
      /// \brief Return a unique integer id for the given node in the blue set.
deba@1018
   626
      ///
deba@1018
   627
      /// Return a unique integer id for the given node in the blue set.
deba@1018
   628
      int id(const BlueNode&) const { return -1; }
deba@1018
   629
deba@1018
   630
      /// \brief Return an integer greater or equal to the maximum
deba@1018
   631
      /// node id in the red set.
deba@1018
   632
      ///
deba@1018
   633
      /// Return an integer greater or equal to the maximum
deba@1018
   634
      /// node id in the red set.
deba@1018
   635
      int maxRedId() const { return -1; }
deba@1018
   636
deba@1018
   637
      /// \brief Return an integer greater or equal to the maximum
deba@1018
   638
      /// node id in the blue set.
deba@1018
   639
      ///
deba@1018
   640
      /// Return an integer greater or equal to the maximum
deba@1018
   641
      /// node id in the blue set.
deba@1018
   642
      int maxBlueId() const { return -1; }
deba@1018
   643
deba@1018
   644
      template <typename _BpGraph>
deba@1018
   645
      struct Constraints {
deba@1018
   646
deba@1018
   647
        void constraints() {
deba@1018
   648
          checkConcept<IDableGraphComponent<Base>, _BpGraph>();
deba@1018
   649
          typename _BpGraph::Node node;
deba@1018
   650
          typename _BpGraph::RedNode red;
deba@1018
   651
          typename _BpGraph::BlueNode blue;
deba@1025
   652
          int rid = bpgraph.id(red);
deba@1025
   653
          int bid = bpgraph.id(blue);
deba@1018
   654
          rid = bpgraph.maxRedId();
deba@1018
   655
          bid = bpgraph.maxBlueId();
alpar@1087
   656
          ::lemon::ignore_unused_variable_warning(rid);
alpar@1087
   657
          ::lemon::ignore_unused_variable_warning(bid);
deba@1018
   658
        }
deba@1018
   659
deba@1018
   660
        const _BpGraph& bpgraph;
deba@1018
   661
      };
deba@1018
   662
    };
deba@1018
   663
kpeter@579
   664
    /// \brief Concept class for \c NodeIt, \c ArcIt and \c EdgeIt types.
deba@57
   665
    ///
alpar@877
   666
    /// This class describes the concept of \c NodeIt, \c ArcIt and
kpeter@579
   667
    /// \c EdgeIt subtypes of digraph and graph types.
kpeter@559
   668
    template <typename GR, typename Item>
kpeter@559
   669
    class GraphItemIt : public Item {
deba@57
   670
    public:
deba@57
   671
      /// \brief Default constructor.
deba@57
   672
      ///
kpeter@579
   673
      /// Default constructor.
kpeter@579
   674
      /// \warning The default constructor is not required to set
kpeter@579
   675
      /// the iterator to some well-defined value. So you should consider it
kpeter@579
   676
      /// as uninitialized.
deba@57
   677
      GraphItemIt() {}
kpeter@579
   678
deba@57
   679
      /// \brief Copy constructor.
deba@57
   680
      ///
deba@57
   681
      /// Copy constructor.
kpeter@579
   682
      GraphItemIt(const GraphItemIt& it) : Item(it) {}
kpeter@579
   683
kpeter@579
   684
      /// \brief Constructor that sets the iterator to the first item.
deba@57
   685
      ///
kpeter@579
   686
      /// Constructor that sets the iterator to the first item.
kpeter@579
   687
      explicit GraphItemIt(const GR&) {}
kpeter@579
   688
kpeter@579
   689
      /// \brief Constructor for conversion from \c INVALID.
deba@57
   690
      ///
kpeter@579
   691
      /// Constructor for conversion from \c INVALID.
kpeter@579
   692
      /// It initializes the iterator to be invalid.
deba@57
   693
      /// \sa Invalid for more details.
deba@57
   694
      GraphItemIt(Invalid) {}
kpeter@579
   695
kpeter@579
   696
      /// \brief Assignment operator.
deba@57
   697
      ///
kpeter@579
   698
      /// Assignment operator for the iterator.
kpeter@579
   699
      GraphItemIt& operator=(const GraphItemIt&) { return *this; }
kpeter@579
   700
kpeter@579
   701
      /// \brief Increment the iterator.
deba@57
   702
      ///
kpeter@579
   703
      /// This operator increments the iterator, i.e. assigns it to the
kpeter@579
   704
      /// next item.
deba@57
   705
      GraphItemIt& operator++() { return *this; }
alpar@877
   706
deba@57
   707
      /// \brief Equality operator
alpar@209
   708
      ///
kpeter@579
   709
      /// Equality operator.
deba@57
   710
      /// Two iterators are equal if and only if they point to the
deba@57
   711
      /// same object or both are invalid.
deba@57
   712
      bool operator==(const GraphItemIt&) const { return true;}
kpeter@579
   713
deba@57
   714
      /// \brief Inequality operator
alpar@209
   715
      ///
kpeter@579
   716
      /// Inequality operator.
kpeter@579
   717
      /// Two iterators are equal if and only if they point to the
kpeter@579
   718
      /// same object or both are invalid.
deba@57
   719
      bool operator!=(const GraphItemIt&) const { return true;}
alpar@209
   720
deba@57
   721
      template<typename _GraphItemIt>
deba@57
   722
      struct Constraints {
alpar@209
   723
        void constraints() {
kpeter@579
   724
          checkConcept<GraphItem<>, _GraphItemIt>();
alpar@209
   725
          _GraphItemIt it1(g);
alpar@209
   726
          _GraphItemIt it2;
kpeter@579
   727
          _GraphItemIt it3 = it1;
kpeter@579
   728
          _GraphItemIt it4 = INVALID;
alpar@1083
   729
          ::lemon::ignore_unused_variable_warning(it3);
alpar@1083
   730
          ::lemon::ignore_unused_variable_warning(it4);
deba@57
   731
alpar@209
   732
          it2 = ++it1;
alpar@209
   733
          ++it2 = it1;
alpar@209
   734
          ++(++it1);
deba@57
   735
kpeter@559
   736
          Item bi = it1;
alpar@209
   737
          bi = it2;
alpar@209
   738
        }
kpeter@579
   739
        const GR& g;
alpar@975
   740
        Constraints() {}
deba@57
   741
      };
deba@57
   742
    };
deba@57
   743
alpar@877
   744
    /// \brief Concept class for \c InArcIt, \c OutArcIt and
kpeter@579
   745
    /// \c IncEdgeIt types.
deba@57
   746
    ///
alpar@877
   747
    /// This class describes the concept of \c InArcIt, \c OutArcIt
kpeter@579
   748
    /// and \c IncEdgeIt subtypes of digraph and graph types.
kpeter@579
   749
    ///
kpeter@579
   750
    /// \note Since these iterator classes do not inherit from the same
kpeter@579
   751
    /// base class, there is an additional template parameter (selector)
alpar@877
   752
    /// \c sel. For \c InArcIt you should instantiate it with character
kpeter@579
   753
    /// \c 'i', for \c OutArcIt with \c 'o' and for \c IncEdgeIt with \c 'e'.
kpeter@559
   754
    template <typename GR,
kpeter@559
   755
              typename Item = typename GR::Arc,
kpeter@559
   756
              typename Base = typename GR::Node,
kpeter@559
   757
              char sel = '0'>
kpeter@559
   758
    class GraphIncIt : public Item {
deba@57
   759
    public:
deba@57
   760
      /// \brief Default constructor.
deba@57
   761
      ///
kpeter@579
   762
      /// Default constructor.
kpeter@579
   763
      /// \warning The default constructor is not required to set
kpeter@579
   764
      /// the iterator to some well-defined value. So you should consider it
kpeter@579
   765
      /// as uninitialized.
deba@57
   766
      GraphIncIt() {}
kpeter@579
   767
deba@57
   768
      /// \brief Copy constructor.
deba@57
   769
      ///
deba@57
   770
      /// Copy constructor.
kpeter@579
   771
      GraphIncIt(const GraphIncIt& it) : Item(it) {}
kpeter@579
   772
alpar@877
   773
      /// \brief Constructor that sets the iterator to the first
kpeter@579
   774
      /// incoming or outgoing arc.
deba@57
   775
      ///
alpar@877
   776
      /// Constructor that sets the iterator to the first arc
kpeter@579
   777
      /// incoming to or outgoing from the given node.
kpeter@579
   778
      explicit GraphIncIt(const GR&, const Base&) {}
kpeter@579
   779
kpeter@579
   780
      /// \brief Constructor for conversion from \c INVALID.
deba@57
   781
      ///
kpeter@579
   782
      /// Constructor for conversion from \c INVALID.
kpeter@579
   783
      /// It initializes the iterator to be invalid.
deba@57
   784
      /// \sa Invalid for more details.
deba@57
   785
      GraphIncIt(Invalid) {}
kpeter@579
   786
kpeter@579
   787
      /// \brief Assignment operator.
deba@57
   788
      ///
kpeter@579
   789
      /// Assignment operator for the iterator.
kpeter@579
   790
      GraphIncIt& operator=(const GraphIncIt&) { return *this; }
kpeter@579
   791
kpeter@579
   792
      /// \brief Increment the iterator.
deba@57
   793
      ///
kpeter@579
   794
      /// This operator increments the iterator, i.e. assigns it to the
kpeter@579
   795
      /// next arc incoming to or outgoing from the given node.
deba@57
   796
      GraphIncIt& operator++() { return *this; }
deba@57
   797
deba@57
   798
      /// \brief Equality operator
deba@57
   799
      ///
kpeter@579
   800
      /// Equality operator.
deba@57
   801
      /// Two iterators are equal if and only if they point to the
deba@57
   802
      /// same object or both are invalid.
deba@57
   803
      bool operator==(const GraphIncIt&) const { return true;}
deba@57
   804
deba@57
   805
      /// \brief Inequality operator
deba@57
   806
      ///
kpeter@579
   807
      /// Inequality operator.
kpeter@579
   808
      /// Two iterators are equal if and only if they point to the
kpeter@579
   809
      /// same object or both are invalid.
deba@57
   810
      bool operator!=(const GraphIncIt&) const { return true;}
deba@57
   811
deba@57
   812
      template <typename _GraphIncIt>
deba@57
   813
      struct Constraints {
alpar@209
   814
        void constraints() {
kpeter@559
   815
          checkConcept<GraphItem<sel>, _GraphIncIt>();
alpar@209
   816
          _GraphIncIt it1(graph, node);
alpar@209
   817
          _GraphIncIt it2;
kpeter@579
   818
          _GraphIncIt it3 = it1;
kpeter@579
   819
          _GraphIncIt it4 = INVALID;
alpar@1083
   820
          ::lemon::ignore_unused_variable_warning(it3);
alpar@1083
   821
          ::lemon::ignore_unused_variable_warning(it4);
deba@57
   822
alpar@209
   823
          it2 = ++it1;
alpar@209
   824
          ++it2 = it1;
alpar@209
   825
          ++(++it1);
kpeter@559
   826
          Item e = it1;
alpar@209
   827
          e = it2;
alpar@209
   828
        }
kpeter@579
   829
        const Base& node;
kpeter@579
   830
        const GR& graph;
alpar@975
   831
        Constraints() {}
deba@57
   832
      };
deba@57
   833
    };
deba@57
   834
kpeter@579
   835
    /// \brief Skeleton class for iterable directed graphs.
deba@57
   836
    ///
kpeter@579
   837
    /// This class describes the interface of iterable directed
kpeter@579
   838
    /// graphs. It extends \ref BaseDigraphComponent with the core
kpeter@579
   839
    /// iterable interface.
deba@57
   840
    /// This concept is part of the Digraph concept.
kpeter@559
   841
    template <typename BAS = BaseDigraphComponent>
kpeter@559
   842
    class IterableDigraphComponent : public BAS {
deba@57
   843
deba@57
   844
    public:
alpar@209
   845
kpeter@559
   846
      typedef BAS Base;
deba@57
   847
      typedef typename Base::Node Node;
deba@57
   848
      typedef typename Base::Arc Arc;
deba@57
   849
deba@57
   850
      typedef IterableDigraphComponent Digraph;
deba@57
   851
kpeter@584
   852
      /// \name Base Iteration
alpar@209
   853
      ///
kpeter@579
   854
      /// This interface provides functions for iteration on digraph items.
deba@57
   855
      ///
alpar@209
   856
      /// @{
deba@57
   857
kpeter@579
   858
      /// \brief Return the first node.
alpar@209
   859
      ///
kpeter@579
   860
      /// This function gives back the first node in the iteration order.
deba@57
   861
      void first(Node&) const {}
deba@57
   862
kpeter@579
   863
      /// \brief Return the next node.
deba@57
   864
      ///
kpeter@579
   865
      /// This function gives back the next node in the iteration order.
deba@57
   866
      void next(Node&) const {}
deba@57
   867
kpeter@579
   868
      /// \brief Return the first arc.
deba@57
   869
      ///
kpeter@579
   870
      /// This function gives back the first arc in the iteration order.
deba@57
   871
      void first(Arc&) const {}
deba@57
   872
kpeter@579
   873
      /// \brief Return the next arc.
deba@57
   874
      ///
kpeter@579
   875
      /// This function gives back the next arc in the iteration order.
deba@57
   876
      void next(Arc&) const {}
deba@57
   877
kpeter@1049
   878
      /// \brief Return the first arc incoming to the given node.
deba@57
   879
      ///
kpeter@1049
   880
      /// This function gives back the first arc incoming to the
kpeter@579
   881
      /// given node.
deba@57
   882
      void firstIn(Arc&, const Node&) const {}
deba@57
   883
kpeter@1049
   884
      /// \brief Return the next arc incoming to the given node.
deba@57
   885
      ///
kpeter@1049
   886
      /// This function gives back the next arc incoming to the
kpeter@579
   887
      /// given node.
deba@57
   888
      void nextIn(Arc&) const {}
deba@57
   889
kpeter@579
   890
      /// \brief Return the first arc outgoing form the given node.
kpeter@579
   891
      ///
kpeter@579
   892
      /// This function gives back the first arc outgoing form the
deba@57
   893
      /// given node.
deba@57
   894
      void firstOut(Arc&, const Node&) const {}
deba@57
   895
kpeter@579
   896
      /// \brief Return the next arc outgoing form the given node.
deba@57
   897
      ///
kpeter@579
   898
      /// This function gives back the next arc outgoing form the
kpeter@579
   899
      /// given node.
deba@57
   900
      void nextOut(Arc&) const {}
deba@57
   901
deba@57
   902
      /// @}
deba@57
   903
kpeter@584
   904
      /// \name Class Based Iteration
alpar@209
   905
      ///
kpeter@579
   906
      /// This interface provides iterator classes for digraph items.
deba@57
   907
      ///
deba@57
   908
      /// @{
deba@57
   909
deba@57
   910
      /// \brief This iterator goes through each node.
deba@57
   911
      ///
deba@57
   912
      /// This iterator goes through each node.
deba@57
   913
      ///
deba@57
   914
      typedef GraphItemIt<Digraph, Node> NodeIt;
deba@57
   915
kpeter@579
   916
      /// \brief This iterator goes through each arc.
deba@57
   917
      ///
kpeter@579
   918
      /// This iterator goes through each arc.
deba@57
   919
      ///
deba@57
   920
      typedef GraphItemIt<Digraph, Arc> ArcIt;
deba@57
   921
deba@57
   922
      /// \brief This iterator goes trough the incoming arcs of a node.
deba@57
   923
      ///
kpeter@579
   924
      /// This iterator goes trough the \e incoming arcs of a certain node
deba@57
   925
      /// of a digraph.
deba@57
   926
      typedef GraphIncIt<Digraph, Arc, Node, 'i'> InArcIt;
deba@57
   927
deba@57
   928
      /// \brief This iterator goes trough the outgoing arcs of a node.
deba@57
   929
      ///
deba@57
   930
      /// This iterator goes trough the \e outgoing arcs of a certain node
deba@57
   931
      /// of a digraph.
deba@57
   932
      typedef GraphIncIt<Digraph, Arc, Node, 'o'> OutArcIt;
deba@57
   933
deba@57
   934
      /// \brief The base node of the iterator.
deba@57
   935
      ///
kpeter@579
   936
      /// This function gives back the base node of the iterator.
kpeter@579
   937
      /// It is always the target node of the pointed arc.
deba@57
   938
      Node baseNode(const InArcIt&) const { return INVALID; }
deba@57
   939
deba@57
   940
      /// \brief The running node of the iterator.
deba@57
   941
      ///
kpeter@579
   942
      /// This function gives back the running node of the iterator.
kpeter@579
   943
      /// It is always the source node of the pointed arc.
deba@57
   944
      Node runningNode(const InArcIt&) const { return INVALID; }
deba@57
   945
deba@57
   946
      /// \brief The base node of the iterator.
deba@57
   947
      ///
kpeter@579
   948
      /// This function gives back the base node of the iterator.
kpeter@579
   949
      /// It is always the source node of the pointed arc.
deba@57
   950
      Node baseNode(const OutArcIt&) const { return INVALID; }
deba@57
   951
deba@57
   952
      /// \brief The running node of the iterator.
deba@57
   953
      ///
kpeter@579
   954
      /// This function gives back the running node of the iterator.
kpeter@579
   955
      /// It is always the target node of the pointed arc.
deba@57
   956
      Node runningNode(const OutArcIt&) const { return INVALID; }
deba@57
   957
deba@57
   958
      /// @}
deba@57
   959
alpar@209
   960
      template <typename _Digraph>
deba@57
   961
      struct Constraints {
alpar@209
   962
        void constraints() {
alpar@209
   963
          checkConcept<Base, _Digraph>();
deba@57
   964
deba@57
   965
          {
alpar@209
   966
            typename _Digraph::Node node(INVALID);
deba@57
   967
            typename _Digraph::Arc arc(INVALID);
deba@57
   968
            {
deba@57
   969
              digraph.first(node);
deba@57
   970
              digraph.next(node);
deba@57
   971
            }
deba@57
   972
            {
deba@57
   973
              digraph.first(arc);
deba@57
   974
              digraph.next(arc);
deba@57
   975
            }
deba@57
   976
            {
deba@57
   977
              digraph.firstIn(arc, node);
deba@57
   978
              digraph.nextIn(arc);
deba@57
   979
            }
deba@57
   980
            {
deba@57
   981
              digraph.firstOut(arc, node);
deba@57
   982
              digraph.nextOut(arc);
deba@57
   983
            }
alpar@209
   984
          }
deba@57
   985
deba@57
   986
          {
deba@57
   987
            checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
deba@57
   988
              typename _Digraph::ArcIt >();
deba@57
   989
            checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
deba@57
   990
              typename _Digraph::NodeIt >();
alpar@209
   991
            checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
deba@57
   992
              typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
alpar@209
   993
            checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
deba@57
   994
              typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
deba@57
   995
deba@57
   996
            typename _Digraph::Node n;
kpeter@579
   997
            const typename _Digraph::InArcIt iait(INVALID);
kpeter@579
   998
            const typename _Digraph::OutArcIt oait(INVALID);
kpeter@579
   999
            n = digraph.baseNode(iait);
kpeter@579
  1000
            n = digraph.runningNode(iait);
kpeter@579
  1001
            n = digraph.baseNode(oait);
kpeter@579
  1002
            n = digraph.runningNode(oait);
alpar@1083
  1003
            ::lemon::ignore_unused_variable_warning(n);
deba@57
  1004
          }
deba@57
  1005
        }
alpar@209
  1006
alpar@209
  1007
        const _Digraph& digraph;
alpar@975
  1008
        Constraints() {}
deba@57
  1009
      };
deba@57
  1010
    };
deba@57
  1011
kpeter@579
  1012
    /// \brief Skeleton class for iterable undirected graphs.
deba@57
  1013
    ///
kpeter@579
  1014
    /// This class describes the interface of iterable undirected
kpeter@579
  1015
    /// graphs. It extends \ref IterableDigraphComponent with the core
kpeter@579
  1016
    /// iterable interface of undirected graphs.
deba@57
  1017
    /// This concept is part of the Graph concept.
kpeter@559
  1018
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1019
    class IterableGraphComponent : public IterableDigraphComponent<BAS> {
deba@57
  1020
    public:
deba@57
  1021
kpeter@559
  1022
      typedef BAS Base;
deba@57
  1023
      typedef typename Base::Node Node;
deba@57
  1024
      typedef typename Base::Arc Arc;
deba@57
  1025
      typedef typename Base::Edge Edge;
deba@57
  1026
alpar@209
  1027
deba@57
  1028
      typedef IterableGraphComponent Graph;
deba@57
  1029
kpeter@584
  1030
      /// \name Base Iteration
alpar@209
  1031
      ///
kpeter@579
  1032
      /// This interface provides functions for iteration on edges.
kpeter@579
  1033
      ///
alpar@209
  1034
      /// @{
deba@57
  1035
kpeter@559
  1036
      using IterableDigraphComponent<Base>::first;
kpeter@559
  1037
      using IterableDigraphComponent<Base>::next;
deba@57
  1038
kpeter@579
  1039
      /// \brief Return the first edge.
deba@57
  1040
      ///
kpeter@579
  1041
      /// This function gives back the first edge in the iteration order.
deba@57
  1042
      void first(Edge&) const {}
deba@57
  1043
kpeter@579
  1044
      /// \brief Return the next edge.
deba@57
  1045
      ///
kpeter@579
  1046
      /// This function gives back the next edge in the iteration order.
deba@57
  1047
      void next(Edge&) const {}
deba@57
  1048
kpeter@579
  1049
      /// \brief Return the first edge incident to the given node.
kpeter@579
  1050
      ///
alpar@877
  1051
      /// This function gives back the first edge incident to the given
kpeter@579
  1052
      /// node. The bool parameter gives back the direction for which the
alpar@877
  1053
      /// source node of the directed arc representing the edge is the
deba@57
  1054
      /// given node.
deba@57
  1055
      void firstInc(Edge&, bool&, const Node&) const {}
deba@57
  1056
deba@57
  1057
      /// \brief Gives back the next of the edges from the
deba@57
  1058
      /// given node.
deba@57
  1059
      ///
alpar@877
  1060
      /// This function gives back the next edge incident to the given
kpeter@579
  1061
      /// node. The bool parameter should be used as \c firstInc() use it.
deba@57
  1062
      void nextInc(Edge&, bool&) const {}
deba@57
  1063
kpeter@559
  1064
      using IterableDigraphComponent<Base>::baseNode;
kpeter@559
  1065
      using IterableDigraphComponent<Base>::runningNode;
deba@57
  1066
deba@57
  1067
      /// @}
deba@57
  1068
kpeter@584
  1069
      /// \name Class Based Iteration
alpar@209
  1070
      ///
kpeter@579
  1071
      /// This interface provides iterator classes for edges.
deba@57
  1072
      ///
deba@57
  1073
      /// @{
deba@57
  1074
kpeter@579
  1075
      /// \brief This iterator goes through each edge.
deba@57
  1076
      ///
kpeter@579
  1077
      /// This iterator goes through each edge.
deba@57
  1078
      typedef GraphItemIt<Graph, Edge> EdgeIt;
kpeter@579
  1079
kpeter@579
  1080
      /// \brief This iterator goes trough the incident edges of a
deba@57
  1081
      /// node.
deba@57
  1082
      ///
kpeter@579
  1083
      /// This iterator goes trough the incident edges of a certain
deba@57
  1084
      /// node of a graph.
kpeter@579
  1085
      typedef GraphIncIt<Graph, Edge, Node, 'e'> IncEdgeIt;
kpeter@579
  1086
deba@57
  1087
      /// \brief The base node of the iterator.
deba@57
  1088
      ///
kpeter@579
  1089
      /// This function gives back the base node of the iterator.
deba@78
  1090
      Node baseNode(const IncEdgeIt&) const { return INVALID; }
deba@57
  1091
deba@57
  1092
      /// \brief The running node of the iterator.
deba@57
  1093
      ///
kpeter@579
  1094
      /// This function gives back the running node of the iterator.
deba@78
  1095
      Node runningNode(const IncEdgeIt&) const { return INVALID; }
deba@57
  1096
deba@57
  1097
      /// @}
deba@57
  1098
alpar@209
  1099
      template <typename _Graph>
deba@57
  1100
      struct Constraints {
alpar@209
  1101
        void constraints() {
alpar@209
  1102
          checkConcept<IterableDigraphComponent<Base>, _Graph>();
deba@57
  1103
deba@57
  1104
          {
deba@57
  1105
            typename _Graph::Node node(INVALID);
deba@57
  1106
            typename _Graph::Edge edge(INVALID);
deba@57
  1107
            bool dir;
deba@57
  1108
            {
deba@57
  1109
              graph.first(edge);
deba@57
  1110
              graph.next(edge);
deba@57
  1111
            }
deba@57
  1112
            {
deba@57
  1113
              graph.firstInc(edge, dir, node);
deba@57
  1114
              graph.nextInc(edge, dir);
deba@57
  1115
            }
alpar@209
  1116
alpar@209
  1117
          }
alpar@209
  1118
deba@57
  1119
          {
deba@57
  1120
            checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
deba@57
  1121
              typename _Graph::EdgeIt >();
alpar@209
  1122
            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
kpeter@579
  1123
              typename _Graph::Node, 'e'>, typename _Graph::IncEdgeIt>();
alpar@209
  1124
deba@57
  1125
            typename _Graph::Node n;
kpeter@579
  1126
            const typename _Graph::IncEdgeIt ieit(INVALID);
kpeter@579
  1127
            n = graph.baseNode(ieit);
kpeter@579
  1128
            n = graph.runningNode(ieit);
deba@57
  1129
          }
deba@57
  1130
        }
alpar@209
  1131
alpar@209
  1132
        const _Graph& graph;
alpar@975
  1133
        Constraints() {}
deba@57
  1134
      };
deba@57
  1135
    };
deba@57
  1136
deba@1018
  1137
    /// \brief Skeleton class for iterable undirected bipartite graphs.
deba@1018
  1138
    ///
deba@1018
  1139
    /// This class describes the interface of iterable undirected
deba@1018
  1140
    /// bipartite graphs. It extends \ref IterableGraphComponent with
deba@1018
  1141
    /// the core iterable interface of undirected bipartite graphs.
deba@1018
  1142
    /// This concept is part of the BpGraph concept.
deba@1018
  1143
    template <typename BAS = BaseBpGraphComponent>
deba@1018
  1144
    class IterableBpGraphComponent : public IterableGraphComponent<BAS> {
deba@1018
  1145
    public:
deba@1018
  1146
deba@1018
  1147
      typedef BAS Base;
deba@1018
  1148
      typedef typename Base::Node Node;
deba@1025
  1149
      typedef typename Base::RedNode RedNode;
deba@1025
  1150
      typedef typename Base::BlueNode BlueNode;
deba@1018
  1151
      typedef typename Base::Arc Arc;
deba@1018
  1152
      typedef typename Base::Edge Edge;
alpar@1092
  1153
deba@1025
  1154
      typedef IterableBpGraphComponent BpGraph;
deba@1018
  1155
deba@1025
  1156
      using IterableGraphComponent<BAS>::first;
deba@1025
  1157
      using IterableGraphComponent<BAS>::next;
deba@1018
  1158
deba@1018
  1159
      /// \name Base Iteration
deba@1018
  1160
      ///
deba@1018
  1161
      /// This interface provides functions for iteration on red and blue nodes.
deba@1018
  1162
      ///
deba@1018
  1163
      /// @{
deba@1018
  1164
deba@1018
  1165
      /// \brief Return the first red node.
deba@1018
  1166
      ///
deba@1018
  1167
      /// This function gives back the first red node in the iteration order.
deba@1025
  1168
      void first(RedNode&) const {}
deba@1018
  1169
deba@1018
  1170
      /// \brief Return the next red node.
deba@1018
  1171
      ///
deba@1018
  1172
      /// This function gives back the next red node in the iteration order.
deba@1025
  1173
      void next(RedNode&) const {}
deba@1018
  1174
deba@1018
  1175
      /// \brief Return the first blue node.
deba@1018
  1176
      ///
deba@1018
  1177
      /// This function gives back the first blue node in the iteration order.
deba@1025
  1178
      void first(BlueNode&) const {}
deba@1018
  1179
deba@1018
  1180
      /// \brief Return the next blue node.
deba@1018
  1181
      ///
deba@1018
  1182
      /// This function gives back the next blue node in the iteration order.
deba@1025
  1183
      void next(BlueNode&) const {}
deba@1018
  1184
deba@1018
  1185
deba@1018
  1186
      /// @}
deba@1018
  1187
deba@1018
  1188
      /// \name Class Based Iteration
deba@1018
  1189
      ///
deba@1018
  1190
      /// This interface provides iterator classes for red and blue nodes.
deba@1018
  1191
      ///
deba@1018
  1192
      /// @{
deba@1018
  1193
deba@1018
  1194
      /// \brief This iterator goes through each red node.
deba@1018
  1195
      ///
deba@1018
  1196
      /// This iterator goes through each red node.
deba@1026
  1197
      typedef GraphItemIt<BpGraph, RedNode> RedNodeIt;
deba@1018
  1198
deba@1018
  1199
      /// \brief This iterator goes through each blue node.
deba@1018
  1200
      ///
deba@1018
  1201
      /// This iterator goes through each blue node.
deba@1026
  1202
      typedef GraphItemIt<BpGraph, BlueNode> BlueNodeIt;
deba@1018
  1203
deba@1018
  1204
      /// @}
deba@1018
  1205
deba@1018
  1206
      template <typename _BpGraph>
deba@1018
  1207
      struct Constraints {
deba@1018
  1208
        void constraints() {
deba@1018
  1209
          checkConcept<IterableGraphComponent<Base>, _BpGraph>();
deba@1018
  1210
deba@1025
  1211
          typename _BpGraph::RedNode rn(INVALID);
deba@1025
  1212
          bpgraph.first(rn);
alpar@1092
  1213
          bpgraph.next(rn);
deba@1025
  1214
          typename _BpGraph::BlueNode bn(INVALID);
deba@1025
  1215
          bpgraph.first(bn);
deba@1025
  1216
          bpgraph.next(bn);
deba@1018
  1217
deba@1025
  1218
          checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::RedNode>,
deba@1026
  1219
            typename _BpGraph::RedNodeIt>();
deba@1025
  1220
          checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::BlueNode>,
deba@1026
  1221
            typename _BpGraph::BlueNodeIt>();
deba@1018
  1222
        }
deba@1018
  1223
deba@1018
  1224
        const _BpGraph& bpgraph;
deba@1018
  1225
      };
deba@1018
  1226
    };
deba@1018
  1227
kpeter@579
  1228
    /// \brief Skeleton class for alterable directed graphs.
alpar@209
  1229
    ///
kpeter@579
  1230
    /// This class describes the interface of alterable directed
kpeter@579
  1231
    /// graphs. It extends \ref BaseDigraphComponent with the alteration
kpeter@579
  1232
    /// notifier interface. It implements
deba@57
  1233
    /// an observer-notifier pattern for each digraph item. More
deba@57
  1234
    /// obsevers can be registered into the notifier and whenever an
kpeter@579
  1235
    /// alteration occured in the digraph all the observers will be
deba@57
  1236
    /// notified about it.
kpeter@559
  1237
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  1238
    class AlterableDigraphComponent : public BAS {
deba@57
  1239
    public:
deba@57
  1240
kpeter@559
  1241
      typedef BAS Base;
deba@57
  1242
      typedef typename Base::Node Node;
deba@57
  1243
      typedef typename Base::Arc Arc;
deba@57
  1244
deba@57
  1245
kpeter@579
  1246
      /// Node alteration notifier class.
alpar@209
  1247
      typedef AlterationNotifier<AlterableDigraphComponent, Node>
deba@57
  1248
      NodeNotifier;
kpeter@579
  1249
      /// Arc alteration notifier class.
alpar@209
  1250
      typedef AlterationNotifier<AlterableDigraphComponent, Arc>
deba@57
  1251
      ArcNotifier;
alpar@209
  1252
deba@1018
  1253
      mutable NodeNotifier node_notifier;
deba@1018
  1254
      mutable ArcNotifier arc_notifier;
deba@1018
  1255
kpeter@579
  1256
      /// \brief Return the node alteration notifier.
deba@57
  1257
      ///
kpeter@579
  1258
      /// This function gives back the node alteration notifier.
deba@57
  1259
      NodeNotifier& notifier(Node) const {
deba@1018
  1260
        return node_notifier;
deba@57
  1261
      }
alpar@209
  1262
kpeter@579
  1263
      /// \brief Return the arc alteration notifier.
deba@57
  1264
      ///
kpeter@579
  1265
      /// This function gives back the arc alteration notifier.
deba@57
  1266
      ArcNotifier& notifier(Arc) const {
deba@1018
  1267
        return arc_notifier;
deba@57
  1268
      }
deba@57
  1269
alpar@209
  1270
      template <typename _Digraph>
deba@57
  1271
      struct Constraints {
alpar@209
  1272
        void constraints() {
alpar@209
  1273
          checkConcept<Base, _Digraph>();
alpar@209
  1274
          typename _Digraph::NodeNotifier& nn
deba@57
  1275
            = digraph.notifier(typename _Digraph::Node());
deba@57
  1276
alpar@209
  1277
          typename _Digraph::ArcNotifier& en
deba@57
  1278
            = digraph.notifier(typename _Digraph::Arc());
alpar@209
  1279
alpar@1083
  1280
          ::lemon::ignore_unused_variable_warning(nn);
alpar@1083
  1281
          ::lemon::ignore_unused_variable_warning(en);
alpar@209
  1282
        }
alpar@209
  1283
alpar@209
  1284
        const _Digraph& digraph;
alpar@975
  1285
        Constraints() {}
deba@57
  1286
      };
deba@57
  1287
    };
deba@57
  1288
kpeter@579
  1289
    /// \brief Skeleton class for alterable undirected graphs.
alpar@209
  1290
    ///
kpeter@579
  1291
    /// This class describes the interface of alterable undirected
kpeter@579
  1292
    /// graphs. It extends \ref AlterableDigraphComponent with the alteration
kpeter@579
  1293
    /// notifier interface of undirected graphs. It implements
kpeter@579
  1294
    /// an observer-notifier pattern for the edges. More
deba@57
  1295
    /// obsevers can be registered into the notifier and whenever an
kpeter@579
  1296
    /// alteration occured in the graph all the observers will be
deba@57
  1297
    /// notified about it.
kpeter@559
  1298
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1299
    class AlterableGraphComponent : public AlterableDigraphComponent<BAS> {
deba@57
  1300
    public:
deba@57
  1301
kpeter@559
  1302
      typedef BAS Base;
deba@1018
  1303
      typedef AlterableDigraphComponent<Base> Parent;
deba@57
  1304
      typedef typename Base::Edge Edge;
deba@57
  1305
deba@57
  1306
kpeter@579
  1307
      /// Edge alteration notifier class.
alpar@209
  1308
      typedef AlterationNotifier<AlterableGraphComponent, Edge>
deba@57
  1309
      EdgeNotifier;
alpar@209
  1310
deba@1018
  1311
      mutable EdgeNotifier edge_notifier;
deba@1018
  1312
deba@1018
  1313
      using Parent::notifier;
deba@1018
  1314
kpeter@579
  1315
      /// \brief Return the edge alteration notifier.
deba@57
  1316
      ///
kpeter@579
  1317
      /// This function gives back the edge alteration notifier.
deba@57
  1318
      EdgeNotifier& notifier(Edge) const {
deba@1018
  1319
        return edge_notifier;
deba@57
  1320
      }
deba@57
  1321
alpar@209
  1322
      template <typename _Graph>
deba@57
  1323
      struct Constraints {
alpar@209
  1324
        void constraints() {
kpeter@579
  1325
          checkConcept<AlterableDigraphComponent<Base>, _Graph>();
alpar@209
  1326
          typename _Graph::EdgeNotifier& uen
deba@57
  1327
            = graph.notifier(typename _Graph::Edge());
alpar@1083
  1328
          ::lemon::ignore_unused_variable_warning(uen);
alpar@209
  1329
        }
alpar@209
  1330
alpar@209
  1331
        const _Graph& graph;
alpar@975
  1332
        Constraints() {}
deba@57
  1333
      };
deba@57
  1334
    };
deba@57
  1335
deba@1018
  1336
    /// \brief Skeleton class for alterable undirected bipartite graphs.
deba@1018
  1337
    ///
deba@1018
  1338
    /// This class describes the interface of alterable undirected
deba@1018
  1339
    /// bipartite graphs. It extends \ref AlterableGraphComponent with
deba@1018
  1340
    /// the alteration notifier interface of bipartite graphs. It
deba@1018
  1341
    /// implements an observer-notifier pattern for the red and blue
deba@1018
  1342
    /// nodes. More obsevers can be registered into the notifier and
deba@1018
  1343
    /// whenever an alteration occured in the graph all the observers
deba@1018
  1344
    /// will be notified about it.
deba@1018
  1345
    template <typename BAS = BaseBpGraphComponent>
deba@1018
  1346
    class AlterableBpGraphComponent : public AlterableGraphComponent<BAS> {
deba@1018
  1347
    public:
deba@1018
  1348
deba@1018
  1349
      typedef BAS Base;
deba@1018
  1350
      typedef AlterableGraphComponent<Base> Parent;
deba@1018
  1351
      typedef typename Base::RedNode RedNode;
deba@1018
  1352
      typedef typename Base::BlueNode BlueNode;
deba@1018
  1353
deba@1018
  1354
deba@1018
  1355
      /// Red node alteration notifier class.
deba@1018
  1356
      typedef AlterationNotifier<AlterableBpGraphComponent, RedNode>
deba@1018
  1357
      RedNodeNotifier;
deba@1018
  1358
deba@1018
  1359
      /// Blue node alteration notifier class.
deba@1018
  1360
      typedef AlterationNotifier<AlterableBpGraphComponent, BlueNode>
deba@1018
  1361
      BlueNodeNotifier;
deba@1018
  1362
deba@1018
  1363
      mutable RedNodeNotifier red_node_notifier;
deba@1018
  1364
      mutable BlueNodeNotifier blue_node_notifier;
deba@1018
  1365
deba@1018
  1366
      using Parent::notifier;
deba@1018
  1367
deba@1018
  1368
      /// \brief Return the red node alteration notifier.
deba@1018
  1369
      ///
deba@1018
  1370
      /// This function gives back the red node alteration notifier.
deba@1018
  1371
      RedNodeNotifier& notifier(RedNode) const {
deba@1018
  1372
        return red_node_notifier;
deba@1018
  1373
      }
deba@1018
  1374
deba@1018
  1375
      /// \brief Return the blue node alteration notifier.
deba@1018
  1376
      ///
deba@1018
  1377
      /// This function gives back the blue node alteration notifier.
deba@1018
  1378
      BlueNodeNotifier& notifier(BlueNode) const {
deba@1018
  1379
        return blue_node_notifier;
deba@1018
  1380
      }
deba@1018
  1381
deba@1018
  1382
      template <typename _BpGraph>
deba@1018
  1383
      struct Constraints {
deba@1018
  1384
        void constraints() {
deba@1018
  1385
          checkConcept<AlterableGraphComponent<Base>, _BpGraph>();
deba@1018
  1386
          typename _BpGraph::RedNodeNotifier& rnn
deba@1018
  1387
            = bpgraph.notifier(typename _BpGraph::RedNode());
deba@1018
  1388
          typename _BpGraph::BlueNodeNotifier& bnn
deba@1018
  1389
            = bpgraph.notifier(typename _BpGraph::BlueNode());
alpar@1087
  1390
          ::lemon::ignore_unused_variable_warning(rnn);
alpar@1087
  1391
          ::lemon::ignore_unused_variable_warning(bnn);
deba@1018
  1392
        }
deba@1018
  1393
deba@1018
  1394
        const _BpGraph& bpgraph;
deba@1018
  1395
      };
deba@1018
  1396
    };
deba@1018
  1397
kpeter@579
  1398
    /// \brief Concept class for standard graph maps.
alpar@209
  1399
    ///
kpeter@579
  1400
    /// This class describes the concept of standard graph maps, i.e.
alpar@877
  1401
    /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and
kpeter@579
  1402
    /// graph types, which can be used for associating data to graph items.
kpeter@580
  1403
    /// The standard graph maps must conform to the ReferenceMap concept.
kpeter@559
  1404
    template <typename GR, typename K, typename V>
kpeter@580
  1405
    class GraphMap : public ReferenceMap<K, V, V&, const V&> {
kpeter@617
  1406
      typedef ReferenceMap<K, V, V&, const V&> Parent;
kpeter@617
  1407
deba@57
  1408
    public:
deba@57
  1409
deba@57
  1410
      /// The key type of the map.
kpeter@559
  1411
      typedef K Key;
deba@57
  1412
      /// The value type of the map.
kpeter@559
  1413
      typedef V Value;
kpeter@580
  1414
      /// The reference type of the map.
kpeter@580
  1415
      typedef Value& Reference;
kpeter@580
  1416
      /// The const reference type of the map.
kpeter@580
  1417
      typedef const Value& ConstReference;
kpeter@580
  1418
kpeter@580
  1419
      // The reference map tag.
kpeter@580
  1420
      typedef True ReferenceMapTag;
deba@57
  1421
deba@57
  1422
      /// \brief Construct a new map.
deba@57
  1423
      ///
deba@57
  1424
      /// Construct a new map for the graph.
kpeter@617
  1425
      explicit GraphMap(const GR&) {}
deba@57
  1426
      /// \brief Construct a new map with default value.
deba@57
  1427
      ///
kpeter@579
  1428
      /// Construct a new map for the graph and initalize the values.
kpeter@617
  1429
      GraphMap(const GR&, const Value&) {}
kpeter@263
  1430
kpeter@263
  1431
    private:
deba@57
  1432
      /// \brief Copy constructor.
deba@57
  1433
      ///
deba@57
  1434
      /// Copy Constructor.
deba@57
  1435
      GraphMap(const GraphMap&) : Parent() {}
alpar@209
  1436
kpeter@579
  1437
      /// \brief Assignment operator.
deba@57
  1438
      ///
kpeter@579
  1439
      /// Assignment operator. It does not mofify the underlying graph,
deba@57
  1440
      /// it just iterates on the current item set and set the  map
alpar@209
  1441
      /// with the value returned by the assigned map.
deba@57
  1442
      template <typename CMap>
alpar@209
  1443
      GraphMap& operator=(const CMap&) {
deba@57
  1444
        checkConcept<ReadMap<Key, Value>, CMap>();
deba@57
  1445
        return *this;
deba@57
  1446
      }
deba@57
  1447
kpeter@263
  1448
    public:
deba@57
  1449
      template<typename _Map>
deba@57
  1450
      struct Constraints {
alpar@209
  1451
        void constraints() {
kpeter@580
  1452
          checkConcept
kpeter@580
  1453
            <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
kpeter@579
  1454
          _Map m1(g);
kpeter@579
  1455
          _Map m2(g,t);
alpar@877
  1456
kpeter@579
  1457
          // Copy constructor
kpeter@579
  1458
          // _Map m3(m);
alpar@209
  1459
kpeter@579
  1460
          // Assignment operator
kpeter@263
  1461
          // ReadMap<Key, Value> cmap;
kpeter@579
  1462
          // m3 = cmap;
deba@57
  1463
alpar@1083
  1464
          ::lemon::ignore_unused_variable_warning(m1);
alpar@1083
  1465
          ::lemon::ignore_unused_variable_warning(m2);
alpar@1083
  1466
          // ::lemon::ignore_unused_variable_warning(m3);
alpar@209
  1467
        }
deba@57
  1468
kpeter@579
  1469
        const _Map &m;
kpeter@617
  1470
        const GR &g;
alpar@209
  1471
        const typename GraphMap::Value &t;
alpar@975
  1472
        Constraints() {}
deba@57
  1473
      };
deba@57
  1474
deba@57
  1475
    };
deba@57
  1476
kpeter@579
  1477
    /// \brief Skeleton class for mappable directed graphs.
deba@57
  1478
    ///
kpeter@579
  1479
    /// This class describes the interface of mappable directed graphs.
alpar@877
  1480
    /// It extends \ref BaseDigraphComponent with the standard digraph
kpeter@579
  1481
    /// map classes, namely \c NodeMap and \c ArcMap.
deba@57
  1482
    /// This concept is part of the Digraph concept.
kpeter@559
  1483
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  1484
    class MappableDigraphComponent : public BAS  {
deba@57
  1485
    public:
deba@57
  1486
kpeter@559
  1487
      typedef BAS Base;
deba@57
  1488
      typedef typename Base::Node Node;
deba@57
  1489
      typedef typename Base::Arc Arc;
deba@57
  1490
deba@57
  1491
      typedef MappableDigraphComponent Digraph;
deba@57
  1492
kpeter@579
  1493
      /// \brief Standard graph map for the nodes.
deba@57
  1494
      ///
kpeter@579
  1495
      /// Standard graph map for the nodes.
kpeter@580
  1496
      /// It conforms to the ReferenceMap concept.
kpeter@559
  1497
      template <typename V>
kpeter@579
  1498
      class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
kpeter@559
  1499
        typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
deba@57
  1500
kpeter@617
  1501
      public:
alpar@209
  1502
        /// \brief Construct a new map.
alpar@209
  1503
        ///
alpar@209
  1504
        /// Construct a new map for the digraph.
alpar@209
  1505
        explicit NodeMap(const MappableDigraphComponent& digraph)
deba@57
  1506
          : Parent(digraph) {}
deba@57
  1507
alpar@209
  1508
        /// \brief Construct a new map with default value.
alpar@209
  1509
        ///
kpeter@579
  1510
        /// Construct a new map for the digraph and initalize the values.
kpeter@559
  1511
        NodeMap(const MappableDigraphComponent& digraph, const V& value)
deba@57
  1512
          : Parent(digraph, value) {}
deba@57
  1513
kpeter@263
  1514
      private:
alpar@209
  1515
        /// \brief Copy constructor.
alpar@209
  1516
        ///
alpar@209
  1517
        /// Copy Constructor.
alpar@209
  1518
        NodeMap(const NodeMap& nm) : Parent(nm) {}
deba@57
  1519
kpeter@579
  1520
        /// \brief Assignment operator.
alpar@209
  1521
        ///
kpeter@579
  1522
        /// Assignment operator.
deba@57
  1523
        template <typename CMap>
alpar@209
  1524
        NodeMap& operator=(const CMap&) {
kpeter@559
  1525
          checkConcept<ReadMap<Node, V>, CMap>();
deba@57
  1526
          return *this;
deba@57
  1527
        }
deba@57
  1528
deba@57
  1529
      };
deba@57
  1530
kpeter@579
  1531
      /// \brief Standard graph map for the arcs.
deba@57
  1532
      ///
kpeter@579
  1533
      /// Standard graph map for the arcs.
kpeter@580
  1534
      /// It conforms to the ReferenceMap concept.
kpeter@559
  1535
      template <typename V>
kpeter@579
  1536
      class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
kpeter@559
  1537
        typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
deba@57
  1538
kpeter@617
  1539
      public:
alpar@209
  1540
        /// \brief Construct a new map.
alpar@209
  1541
        ///
alpar@209
  1542
        /// Construct a new map for the digraph.
alpar@209
  1543
        explicit ArcMap(const MappableDigraphComponent& digraph)
deba@57
  1544
          : Parent(digraph) {}
deba@57
  1545
alpar@209
  1546
        /// \brief Construct a new map with default value.
alpar@209
  1547
        ///
kpeter@579
  1548
        /// Construct a new map for the digraph and initalize the values.
kpeter@559
  1549
        ArcMap(const MappableDigraphComponent& digraph, const V& value)
deba@57
  1550
          : Parent(digraph, value) {}
deba@57
  1551
kpeter@263
  1552
      private:
alpar@209
  1553
        /// \brief Copy constructor.
alpar@209
  1554
        ///
alpar@209
  1555
        /// Copy Constructor.
alpar@209
  1556
        ArcMap(const ArcMap& nm) : Parent(nm) {}
deba@57
  1557
kpeter@579
  1558
        /// \brief Assignment operator.
alpar@209
  1559
        ///
kpeter@579
  1560
        /// Assignment operator.
deba@57
  1561
        template <typename CMap>
alpar@209
  1562
        ArcMap& operator=(const CMap&) {
kpeter@559
  1563
          checkConcept<ReadMap<Arc, V>, CMap>();
deba@57
  1564
          return *this;
deba@57
  1565
        }
deba@57
  1566
deba@57
  1567
      };
deba@57
  1568
deba@57
  1569
deba@57
  1570
      template <typename _Digraph>
deba@57
  1571
      struct Constraints {
deba@57
  1572
alpar@209
  1573
        struct Dummy {
alpar@209
  1574
          int value;
alpar@209
  1575
          Dummy() : value(0) {}
alpar@209
  1576
          Dummy(int _v) : value(_v) {}
alpar@209
  1577
        };
deba@57
  1578
alpar@209
  1579
        void constraints() {
alpar@209
  1580
          checkConcept<Base, _Digraph>();
alpar@209
  1581
          { // int map test
alpar@209
  1582
            typedef typename _Digraph::template NodeMap<int> IntNodeMap;
alpar@209
  1583
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
alpar@209
  1584
              IntNodeMap >();
alpar@209
  1585
          } { // bool map test
alpar@209
  1586
            typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
alpar@209
  1587
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
alpar@209
  1588
              BoolNodeMap >();
alpar@209
  1589
          } { // Dummy map test
alpar@209
  1590
            typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
alpar@209
  1591
            checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
alpar@209
  1592
              DummyNodeMap >();
alpar@209
  1593
          }
deba@57
  1594
alpar@209
  1595
          { // int map test
alpar@209
  1596
            typedef typename _Digraph::template ArcMap<int> IntArcMap;
alpar@209
  1597
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
alpar@209
  1598
              IntArcMap >();
alpar@209
  1599
          } { // bool map test
alpar@209
  1600
            typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
alpar@209
  1601
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
alpar@209
  1602
              BoolArcMap >();
alpar@209
  1603
          } { // Dummy map test
alpar@209
  1604
            typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
alpar@209
  1605
            checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
alpar@209
  1606
              DummyArcMap >();
alpar@209
  1607
          }
alpar@209
  1608
        }
deba@57
  1609
kpeter@579
  1610
        const _Digraph& digraph;
alpar@975
  1611
        Constraints() {}
deba@57
  1612
      };
deba@57
  1613
    };
deba@57
  1614
kpeter@579
  1615
    /// \brief Skeleton class for mappable undirected graphs.
deba@57
  1616
    ///
kpeter@579
  1617
    /// This class describes the interface of mappable undirected graphs.
alpar@877
  1618
    /// It extends \ref MappableDigraphComponent with the standard graph
kpeter@579
  1619
    /// map class for edges (\c EdgeMap).
deba@57
  1620
    /// This concept is part of the Graph concept.
kpeter@559
  1621
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1622
    class MappableGraphComponent : public MappableDigraphComponent<BAS>  {
deba@57
  1623
    public:
deba@57
  1624
kpeter@559
  1625
      typedef BAS Base;
deba@57
  1626
      typedef typename Base::Edge Edge;
deba@57
  1627
deba@57
  1628
      typedef MappableGraphComponent Graph;
deba@57
  1629
kpeter@579
  1630
      /// \brief Standard graph map for the edges.
deba@57
  1631
      ///
kpeter@579
  1632
      /// Standard graph map for the edges.
kpeter@580
  1633
      /// It conforms to the ReferenceMap concept.
kpeter@559
  1634
      template <typename V>
kpeter@579
  1635
      class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
kpeter@559
  1636
        typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
deba@57
  1637
kpeter@617
  1638
      public:
alpar@209
  1639
        /// \brief Construct a new map.
alpar@209
  1640
        ///
alpar@209
  1641
        /// Construct a new map for the graph.
alpar@209
  1642
        explicit EdgeMap(const MappableGraphComponent& graph)
deba@57
  1643
          : Parent(graph) {}
deba@57
  1644
alpar@209
  1645
        /// \brief Construct a new map with default value.
alpar@209
  1646
        ///
kpeter@579
  1647
        /// Construct a new map for the graph and initalize the values.
kpeter@559
  1648
        EdgeMap(const MappableGraphComponent& graph, const V& value)
deba@57
  1649
          : Parent(graph, value) {}
deba@57
  1650
kpeter@263
  1651
      private:
alpar@209
  1652
        /// \brief Copy constructor.
alpar@209
  1653
        ///
alpar@209
  1654
        /// Copy Constructor.
alpar@209
  1655
        EdgeMap(const EdgeMap& nm) : Parent(nm) {}
deba@57
  1656
kpeter@579
  1657
        /// \brief Assignment operator.
alpar@209
  1658
        ///
kpeter@579
  1659
        /// Assignment operator.
deba@57
  1660
        template <typename CMap>
alpar@209
  1661
        EdgeMap& operator=(const CMap&) {
kpeter@559
  1662
          checkConcept<ReadMap<Edge, V>, CMap>();
deba@57
  1663
          return *this;
deba@57
  1664
        }
deba@57
  1665
deba@57
  1666
      };
deba@57
  1667
deba@57
  1668
deba@57
  1669
      template <typename _Graph>
deba@57
  1670
      struct Constraints {
deba@57
  1671
alpar@209
  1672
        struct Dummy {
alpar@209
  1673
          int value;
alpar@209
  1674
          Dummy() : value(0) {}
alpar@209
  1675
          Dummy(int _v) : value(_v) {}
alpar@209
  1676
        };
deba@57
  1677
alpar@209
  1678
        void constraints() {
kpeter@579
  1679
          checkConcept<MappableDigraphComponent<Base>, _Graph>();
deba@57
  1680
alpar@209
  1681
          { // int map test
alpar@209
  1682
            typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
alpar@209
  1683
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
alpar@209
  1684
              IntEdgeMap >();
alpar@209
  1685
          } { // bool map test
alpar@209
  1686
            typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
alpar@209
  1687
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
alpar@209
  1688
              BoolEdgeMap >();
alpar@209
  1689
          } { // Dummy map test
alpar@209
  1690
            typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
alpar@209
  1691
            checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
alpar@209
  1692
              DummyEdgeMap >();
alpar@209
  1693
          }
alpar@209
  1694
        }
deba@57
  1695
kpeter@579
  1696
        const _Graph& graph;
alpar@975
  1697
        Constraints() {}
deba@57
  1698
      };
deba@57
  1699
    };
deba@57
  1700
deba@1018
  1701
    /// \brief Skeleton class for mappable undirected bipartite graphs.
deba@1018
  1702
    ///
deba@1018
  1703
    /// This class describes the interface of mappable undirected
deba@1018
  1704
    /// bipartite graphs.  It extends \ref MappableGraphComponent with
deba@1018
  1705
    /// the standard graph map class for red and blue nodes (\c
deba@1026
  1706
    /// RedNodeMap and BlueNodeMap). This concept is part of the
deba@1026
  1707
    /// BpGraph concept.
deba@1018
  1708
    template <typename BAS = BaseBpGraphComponent>
deba@1018
  1709
    class MappableBpGraphComponent : public MappableGraphComponent<BAS>  {
deba@1018
  1710
    public:
deba@1018
  1711
deba@1018
  1712
      typedef BAS Base;
deba@1018
  1713
      typedef typename Base::Node Node;
deba@1018
  1714
deba@1018
  1715
      typedef MappableBpGraphComponent BpGraph;
deba@1018
  1716
deba@1018
  1717
      /// \brief Standard graph map for the red nodes.
deba@1018
  1718
      ///
deba@1018
  1719
      /// Standard graph map for the red nodes.
deba@1018
  1720
      /// It conforms to the ReferenceMap concept.
deba@1018
  1721
      template <typename V>
deba@1026
  1722
      class RedNodeMap : public GraphMap<MappableBpGraphComponent, Node, V> {
deba@1018
  1723
        typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
deba@1018
  1724
deba@1018
  1725
      public:
deba@1018
  1726
        /// \brief Construct a new map.
deba@1018
  1727
        ///
deba@1018
  1728
        /// Construct a new map for the graph.
deba@1026
  1729
        explicit RedNodeMap(const MappableBpGraphComponent& graph)
deba@1018
  1730
          : Parent(graph) {}
deba@1018
  1731
deba@1018
  1732
        /// \brief Construct a new map with default value.
deba@1018
  1733
        ///
deba@1018
  1734
        /// Construct a new map for the graph and initalize the values.
deba@1026
  1735
        RedNodeMap(const MappableBpGraphComponent& graph, const V& value)
deba@1018
  1736
          : Parent(graph, value) {}
deba@1018
  1737
deba@1018
  1738
      private:
deba@1018
  1739
        /// \brief Copy constructor.
deba@1018
  1740
        ///
deba@1018
  1741
        /// Copy Constructor.
deba@1026
  1742
        RedNodeMap(const RedNodeMap& nm) : Parent(nm) {}
deba@1018
  1743
deba@1018
  1744
        /// \brief Assignment operator.
deba@1018
  1745
        ///
deba@1018
  1746
        /// Assignment operator.
deba@1018
  1747
        template <typename CMap>
deba@1026
  1748
        RedNodeMap& operator=(const CMap&) {
deba@1018
  1749
          checkConcept<ReadMap<Node, V>, CMap>();
deba@1018
  1750
          return *this;
deba@1018
  1751
        }
deba@1018
  1752
deba@1018
  1753
      };
deba@1018
  1754
deba@1018
  1755
      /// \brief Standard graph map for the blue nodes.
deba@1018
  1756
      ///
deba@1018
  1757
      /// Standard graph map for the blue nodes.
deba@1018
  1758
      /// It conforms to the ReferenceMap concept.
deba@1018
  1759
      template <typename V>
deba@1026
  1760
      class BlueNodeMap : public GraphMap<MappableBpGraphComponent, Node, V> {
deba@1018
  1761
        typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
deba@1018
  1762
deba@1018
  1763
      public:
deba@1018
  1764
        /// \brief Construct a new map.
deba@1018
  1765
        ///
deba@1018
  1766
        /// Construct a new map for the graph.
deba@1026
  1767
        explicit BlueNodeMap(const MappableBpGraphComponent& graph)
deba@1018
  1768
          : Parent(graph) {}
deba@1018
  1769
deba@1018
  1770
        /// \brief Construct a new map with default value.
deba@1018
  1771
        ///
deba@1018
  1772
        /// Construct a new map for the graph and initalize the values.
deba@1026
  1773
        BlueNodeMap(const MappableBpGraphComponent& graph, const V& value)
deba@1018
  1774
          : Parent(graph, value) {}
deba@1018
  1775
deba@1018
  1776
      private:
deba@1018
  1777
        /// \brief Copy constructor.
deba@1018
  1778
        ///
deba@1018
  1779
        /// Copy Constructor.
deba@1026
  1780
        BlueNodeMap(const BlueNodeMap& nm) : Parent(nm) {}
deba@1018
  1781
deba@1018
  1782
        /// \brief Assignment operator.
deba@1018
  1783
        ///
deba@1018
  1784
        /// Assignment operator.
deba@1018
  1785
        template <typename CMap>
deba@1026
  1786
        BlueNodeMap& operator=(const CMap&) {
deba@1018
  1787
          checkConcept<ReadMap<Node, V>, CMap>();
deba@1018
  1788
          return *this;
deba@1018
  1789
        }
deba@1018
  1790
deba@1018
  1791
      };
deba@1018
  1792
deba@1018
  1793
deba@1018
  1794
      template <typename _BpGraph>
deba@1018
  1795
      struct Constraints {
deba@1018
  1796
deba@1018
  1797
        struct Dummy {
deba@1018
  1798
          int value;
deba@1018
  1799
          Dummy() : value(0) {}
deba@1018
  1800
          Dummy(int _v) : value(_v) {}
deba@1018
  1801
        };
deba@1018
  1802
deba@1018
  1803
        void constraints() {
deba@1018
  1804
          checkConcept<MappableGraphComponent<Base>, _BpGraph>();
deba@1018
  1805
deba@1018
  1806
          { // int map test
deba@1026
  1807
            typedef typename _BpGraph::template RedNodeMap<int>
deba@1026
  1808
              IntRedNodeMap;
deba@1025
  1809
            checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, int>,
deba@1026
  1810
              IntRedNodeMap >();
deba@1018
  1811
          } { // bool map test
deba@1026
  1812
            typedef typename _BpGraph::template RedNodeMap<bool>
deba@1026
  1813
              BoolRedNodeMap;
deba@1025
  1814
            checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, bool>,
deba@1026
  1815
              BoolRedNodeMap >();
deba@1018
  1816
          } { // Dummy map test
deba@1026
  1817
            typedef typename _BpGraph::template RedNodeMap<Dummy>
deba@1026
  1818
              DummyRedNodeMap;
deba@1025
  1819
            checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, Dummy>,
deba@1026
  1820
              DummyRedNodeMap >();
deba@1018
  1821
          }
deba@1018
  1822
deba@1018
  1823
          { // int map test
deba@1026
  1824
            typedef typename _BpGraph::template BlueNodeMap<int>
deba@1026
  1825
              IntBlueNodeMap;
deba@1025
  1826
            checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, int>,
deba@1026
  1827
              IntBlueNodeMap >();
deba@1018
  1828
          } { // bool map test
deba@1026
  1829
            typedef typename _BpGraph::template BlueNodeMap<bool>
deba@1026
  1830
              BoolBlueNodeMap;
deba@1025
  1831
            checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, bool>,
deba@1026
  1832
              BoolBlueNodeMap >();
deba@1018
  1833
          } { // Dummy map test
deba@1026
  1834
            typedef typename _BpGraph::template BlueNodeMap<Dummy>
deba@1026
  1835
              DummyBlueNodeMap;
deba@1025
  1836
            checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, Dummy>,
deba@1026
  1837
              DummyBlueNodeMap >();
deba@1018
  1838
          }
deba@1018
  1839
        }
deba@1018
  1840
deba@1018
  1841
        const _BpGraph& bpgraph;
deba@1018
  1842
      };
deba@1018
  1843
    };
deba@1018
  1844
kpeter@579
  1845
    /// \brief Skeleton class for extendable directed graphs.
deba@57
  1846
    ///
kpeter@579
  1847
    /// This class describes the interface of extendable directed graphs.
alpar@877
  1848
    /// It extends \ref BaseDigraphComponent with functions for adding
kpeter@579
  1849
    /// nodes and arcs to the digraph.
kpeter@579
  1850
    /// This concept requires \ref AlterableDigraphComponent.
kpeter@559
  1851
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  1852
    class ExtendableDigraphComponent : public BAS {
deba@57
  1853
    public:
kpeter@559
  1854
      typedef BAS Base;
deba@57
  1855
kpeter@559
  1856
      typedef typename Base::Node Node;
kpeter@559
  1857
      typedef typename Base::Arc Arc;
deba@57
  1858
kpeter@579
  1859
      /// \brief Add a new node to the digraph.
deba@57
  1860
      ///
kpeter@579
  1861
      /// This function adds a new node to the digraph.
deba@57
  1862
      Node addNode() {
alpar@209
  1863
        return INVALID;
deba@57
  1864
      }
alpar@209
  1865
kpeter@579
  1866
      /// \brief Add a new arc connecting the given two nodes.
deba@57
  1867
      ///
kpeter@579
  1868
      /// This function adds a new arc connecting the given two nodes
kpeter@579
  1869
      /// of the digraph.
deba@57
  1870
      Arc addArc(const Node&, const Node&) {
alpar@209
  1871
        return INVALID;
deba@57
  1872
      }
deba@57
  1873
deba@57
  1874
      template <typename _Digraph>
deba@57
  1875
      struct Constraints {
alpar@209
  1876
        void constraints() {
deba@57
  1877
          checkConcept<Base, _Digraph>();
alpar@209
  1878
          typename _Digraph::Node node_a, node_b;
alpar@209
  1879
          node_a = digraph.addNode();
alpar@209
  1880
          node_b = digraph.addNode();
alpar@209
  1881
          typename _Digraph::Arc arc;
alpar@209
  1882
          arc = digraph.addArc(node_a, node_b);
alpar@209
  1883
        }
deba@57
  1884
alpar@209
  1885
        _Digraph& digraph;
alpar@975
  1886
        Constraints() {}
deba@57
  1887
      };
deba@57
  1888
    };
deba@57
  1889
kpeter@579
  1890
    /// \brief Skeleton class for extendable undirected graphs.
deba@57
  1891
    ///
kpeter@579
  1892
    /// This class describes the interface of extendable undirected graphs.
alpar@877
  1893
    /// It extends \ref BaseGraphComponent with functions for adding
kpeter@579
  1894
    /// nodes and edges to the graph.
kpeter@579
  1895
    /// This concept requires \ref AlterableGraphComponent.
kpeter@559
  1896
    template <typename BAS = BaseGraphComponent>
kpeter@559
  1897
    class ExtendableGraphComponent : public BAS {
deba@57
  1898
    public:
deba@57
  1899
kpeter@559
  1900
      typedef BAS Base;
kpeter@559
  1901
      typedef typename Base::Node Node;
kpeter@559
  1902
      typedef typename Base::Edge Edge;
deba@57
  1903
kpeter@579
  1904
      /// \brief Add a new node to the digraph.
deba@57
  1905
      ///
kpeter@579
  1906
      /// This function adds a new node to the digraph.
deba@57
  1907
      Node addNode() {
alpar@209
  1908
        return INVALID;
deba@57
  1909
      }
alpar@209
  1910
kpeter@579
  1911
      /// \brief Add a new edge connecting the given two nodes.
deba@57
  1912
      ///
kpeter@579
  1913
      /// This function adds a new edge connecting the given two nodes
kpeter@579
  1914
      /// of the graph.
kpeter@579
  1915
      Edge addEdge(const Node&, const Node&) {
alpar@209
  1916
        return INVALID;
deba@57
  1917
      }
deba@57
  1918
deba@57
  1919
      template <typename _Graph>
deba@57
  1920
      struct Constraints {
alpar@209
  1921
        void constraints() {
alpar@209
  1922
          checkConcept<Base, _Graph>();
alpar@209
  1923
          typename _Graph::Node node_a, node_b;
alpar@209
  1924
          node_a = graph.addNode();
alpar@209
  1925
          node_b = graph.addNode();
alpar@209
  1926
          typename _Graph::Edge edge;
alpar@209
  1927
          edge = graph.addEdge(node_a, node_b);
alpar@209
  1928
        }
deba@57
  1929
alpar@209
  1930
        _Graph& graph;
alpar@975
  1931
        Constraints() {}
deba@57
  1932
      };
deba@57
  1933
    };
deba@57
  1934
deba@1018
  1935
    /// \brief Skeleton class for extendable undirected bipartite graphs.
deba@1018
  1936
    ///
deba@1018
  1937
    /// This class describes the interface of extendable undirected
deba@1018
  1938
    /// bipartite graphs. It extends \ref BaseGraphComponent with
deba@1018
  1939
    /// functions for adding nodes and edges to the graph. This
deba@1018
  1940
    /// concept requires \ref AlterableBpGraphComponent.
deba@1018
  1941
    template <typename BAS = BaseBpGraphComponent>
deba@1018
  1942
    class ExtendableBpGraphComponent : public BAS {
deba@1018
  1943
    public:
deba@1018
  1944
deba@1018
  1945
      typedef BAS Base;
deba@1018
  1946
      typedef typename Base::Node Node;
deba@1025
  1947
      typedef typename Base::RedNode RedNode;
deba@1025
  1948
      typedef typename Base::BlueNode BlueNode;
deba@1018
  1949
      typedef typename Base::Edge Edge;
deba@1018
  1950
deba@1018
  1951
      /// \brief Add a new red node to the digraph.
deba@1018
  1952
      ///
deba@1018
  1953
      /// This function adds a red new node to the digraph.
deba@1025
  1954
      RedNode addRedNode() {
deba@1018
  1955
        return INVALID;
deba@1018
  1956
      }
deba@1018
  1957
deba@1018
  1958
      /// \brief Add a new blue node to the digraph.
deba@1018
  1959
      ///
deba@1018
  1960
      /// This function adds a blue new node to the digraph.
deba@1025
  1961
      BlueNode addBlueNode() {
deba@1018
  1962
        return INVALID;
deba@1018
  1963
      }
deba@1018
  1964
deba@1018
  1965
      /// \brief Add a new edge connecting the given two nodes.
deba@1018
  1966
      ///
deba@1018
  1967
      /// This function adds a new edge connecting the given two nodes
deba@1018
  1968
      /// of the graph. The first node has to be a red node, and the
deba@1018
  1969
      /// second one a blue node.
deba@1025
  1970
      Edge addEdge(const RedNode&, const BlueNode&) {
deba@1025
  1971
        return INVALID;
deba@1025
  1972
      }
deba@1025
  1973
      Edge addEdge(const BlueNode&, const RedNode&) {
deba@1018
  1974
        return INVALID;
deba@1018
  1975
      }
deba@1018
  1976
deba@1018
  1977
      template <typename _BpGraph>
deba@1018
  1978
      struct Constraints {
deba@1018
  1979
        void constraints() {
deba@1018
  1980
          checkConcept<Base, _BpGraph>();
deba@1025
  1981
          typename _BpGraph::RedNode red_node;
deba@1025
  1982
          typename _BpGraph::BlueNode blue_node;
deba@1018
  1983
          red_node = bpgraph.addRedNode();
deba@1018
  1984
          blue_node = bpgraph.addBlueNode();
deba@1018
  1985
          typename _BpGraph::Edge edge;
deba@1018
  1986
          edge = bpgraph.addEdge(red_node, blue_node);
deba@1025
  1987
          edge = bpgraph.addEdge(blue_node, red_node);
deba@1018
  1988
        }
deba@1018
  1989
deba@1018
  1990
        _BpGraph& bpgraph;
deba@1018
  1991
      };
deba@1018
  1992
    };
deba@1018
  1993
kpeter@579
  1994
    /// \brief Skeleton class for erasable directed graphs.
alpar@209
  1995
    ///
kpeter@579
  1996
    /// This class describes the interface of erasable directed graphs.
alpar@877
  1997
    /// It extends \ref BaseDigraphComponent with functions for removing
kpeter@579
  1998
    /// nodes and arcs from the digraph.
kpeter@579
  1999
    /// This concept requires \ref AlterableDigraphComponent.
kpeter@559
  2000
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  2001
    class ErasableDigraphComponent : public BAS {
deba@57
  2002
    public:
deba@57
  2003
kpeter@559
  2004
      typedef BAS Base;
deba@57
  2005
      typedef typename Base::Node Node;
deba@57
  2006
      typedef typename Base::Arc Arc;
deba@57
  2007
deba@57
  2008
      /// \brief Erase a node from the digraph.
deba@57
  2009
      ///
alpar@877
  2010
      /// This function erases the given node from the digraph and all arcs
kpeter@579
  2011
      /// connected to the node.
alpar@209
  2012
      void erase(const Node&) {}
deba@57
  2013
deba@57
  2014
      /// \brief Erase an arc from the digraph.
deba@57
  2015
      ///
kpeter@579
  2016
      /// This function erases the given arc from the digraph.
deba@57
  2017
      void erase(const Arc&) {}
deba@57
  2018
deba@57
  2019
      template <typename _Digraph>
deba@57
  2020
      struct Constraints {
alpar@209
  2021
        void constraints() {
deba@57
  2022
          checkConcept<Base, _Digraph>();
kpeter@579
  2023
          const typename _Digraph::Node node(INVALID);
alpar@209
  2024
          digraph.erase(node);
kpeter@579
  2025
          const typename _Digraph::Arc arc(INVALID);
alpar@209
  2026
          digraph.erase(arc);
alpar@209
  2027
        }
deba@57
  2028
alpar@209
  2029
        _Digraph& digraph;
alpar@975
  2030
        Constraints() {}
deba@57
  2031
      };
deba@57
  2032
    };
deba@57
  2033
kpeter@579
  2034
    /// \brief Skeleton class for erasable undirected graphs.
alpar@209
  2035
    ///
kpeter@579
  2036
    /// This class describes the interface of erasable undirected graphs.
alpar@877
  2037
    /// It extends \ref BaseGraphComponent with functions for removing
kpeter@579
  2038
    /// nodes and edges from the graph.
kpeter@579
  2039
    /// This concept requires \ref AlterableGraphComponent.
kpeter@559
  2040
    template <typename BAS = BaseGraphComponent>
kpeter@559
  2041
    class ErasableGraphComponent : public BAS {
deba@57
  2042
    public:
deba@57
  2043
kpeter@559
  2044
      typedef BAS Base;
deba@57
  2045
      typedef typename Base::Node Node;
deba@57
  2046
      typedef typename Base::Edge Edge;
deba@57
  2047
deba@57
  2048
      /// \brief Erase a node from the graph.
deba@57
  2049
      ///
kpeter@579
  2050
      /// This function erases the given node from the graph and all edges
kpeter@579
  2051
      /// connected to the node.
alpar@209
  2052
      void erase(const Node&) {}
deba@57
  2053
kpeter@579
  2054
      /// \brief Erase an edge from the digraph.
deba@57
  2055
      ///
kpeter@579
  2056
      /// This function erases the given edge from the digraph.
deba@57
  2057
      void erase(const Edge&) {}
deba@57
  2058
deba@57
  2059
      template <typename _Graph>
deba@57
  2060
      struct Constraints {
alpar@209
  2061
        void constraints() {
deba@57
  2062
          checkConcept<Base, _Graph>();
kpeter@579
  2063
          const typename _Graph::Node node(INVALID);
alpar@209
  2064
          graph.erase(node);
kpeter@579
  2065
          const typename _Graph::Edge edge(INVALID);
alpar@209
  2066
          graph.erase(edge);
alpar@209
  2067
        }
deba@57
  2068
alpar@209
  2069
        _Graph& graph;
alpar@975
  2070
        Constraints() {}
deba@57
  2071
      };
deba@57
  2072
    };
deba@57
  2073
deba@1018
  2074
    /// \brief Skeleton class for erasable undirected graphs.
deba@1018
  2075
    ///
deba@1018
  2076
    /// This class describes the interface of erasable undirected
deba@1018
  2077
    /// bipartite graphs. It extends \ref BaseBpGraphComponent with
deba@1018
  2078
    /// functions for removing nodes and edges from the graph. This
deba@1018
  2079
    /// concept requires \ref AlterableBpGraphComponent.
deba@1018
  2080
    template <typename BAS = BaseBpGraphComponent>
deba@1018
  2081
    class ErasableBpGraphComponent : public ErasableGraphComponent<BAS> {};
deba@1018
  2082
kpeter@579
  2083
    /// \brief Skeleton class for clearable directed graphs.
deba@57
  2084
    ///
kpeter@579
  2085
    /// This class describes the interface of clearable directed graphs.
kpeter@579
  2086
    /// It extends \ref BaseDigraphComponent with a function for clearing
kpeter@579
  2087
    /// the digraph.
kpeter@579
  2088
    /// This concept requires \ref AlterableDigraphComponent.
kpeter@559
  2089
    template <typename BAS = BaseDigraphComponent>
kpeter@559
  2090
    class ClearableDigraphComponent : public BAS {
deba@57
  2091
    public:
deba@57
  2092
kpeter@559
  2093
      typedef BAS Base;
deba@57
  2094
deba@57
  2095
      /// \brief Erase all nodes and arcs from the digraph.
deba@57
  2096
      ///
kpeter@579
  2097
      /// This function erases all nodes and arcs from the digraph.
alpar@209
  2098
      void clear() {}
deba@57
  2099
deba@57
  2100
      template <typename _Digraph>
deba@57
  2101
      struct Constraints {
alpar@209
  2102
        void constraints() {
deba@57
  2103
          checkConcept<Base, _Digraph>();
alpar@209
  2104
          digraph.clear();
alpar@209
  2105
        }
deba@57
  2106
kpeter@579
  2107
        _Digraph& digraph;
alpar@975
  2108
        Constraints() {}
deba@57
  2109
      };
deba@57
  2110
    };
deba@57
  2111
kpeter@579
  2112
    /// \brief Skeleton class for clearable undirected graphs.
deba@57
  2113
    ///
kpeter@579
  2114
    /// This class describes the interface of clearable undirected graphs.
kpeter@579
  2115
    /// It extends \ref BaseGraphComponent with a function for clearing
kpeter@579
  2116
    /// the graph.
kpeter@579
  2117
    /// This concept requires \ref AlterableGraphComponent.
kpeter@559
  2118
    template <typename BAS = BaseGraphComponent>
deba@1018
  2119
    class ClearableGraphComponent : public ClearableDigraphComponent<BAS> {};
deba@57
  2120
deba@1018
  2121
    /// \brief Skeleton class for clearable undirected biparite graphs.
deba@1018
  2122
    ///
deba@1018
  2123
    /// This class describes the interface of clearable undirected
deba@1018
  2124
    /// bipartite graphs. It extends \ref BaseBpGraphComponent with a
deba@1018
  2125
    /// function for clearing the graph.  This concept requires \ref
deba@1018
  2126
    /// AlterableBpGraphComponent.
deba@1018
  2127
    template <typename BAS = BaseBpGraphComponent>
deba@1018
  2128
    class ClearableBpGraphComponent : public ClearableGraphComponent<BAS> {};
deba@57
  2129
deba@57
  2130
  }
deba@57
  2131
deba@57
  2132
}
deba@57
  2133
deba@57
  2134
#endif