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