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