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