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