lemon/concepts/bpgraph.h
author Alpar Juttner <alpar@cs.elte.hu>
Tue, 28 Jul 2020 21:23:36 +0200
changeset 1210 da87dbdf3daf
parent 1130 0759d974de81
permissions -rw-r--r--
Resolve deprecation warnings of gcc 9 (#633)
deba@1018
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
deba@1018
     2
 *
deba@1018
     3
 * This file is a part of LEMON, a generic C++ optimization library.
deba@1018
     4
 *
alpar@1092
     5
 * Copyright (C) 2003-2013
deba@1018
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@1018
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@1018
     8
 *
deba@1018
     9
 * Permission to use, modify and distribute this software is granted
deba@1018
    10
 * provided that this copyright notice appears in all copies. For
deba@1018
    11
 * precise terms see the accompanying LICENSE file.
deba@1018
    12
 *
deba@1018
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@1018
    14
 * express or implied, and with no claim as to its suitability for any
deba@1018
    15
 * purpose.
deba@1018
    16
 *
deba@1018
    17
 */
deba@1018
    18
deba@1018
    19
///\ingroup graph_concepts
deba@1018
    20
///\file
deba@1018
    21
///\brief The concept of undirected graphs.
deba@1018
    22
deba@1018
    23
#ifndef LEMON_CONCEPTS_BPGRAPH_H
deba@1018
    24
#define LEMON_CONCEPTS_BPGRAPH_H
deba@1018
    25
deba@1018
    26
#include <lemon/concepts/graph_components.h>
deba@1018
    27
#include <lemon/concepts/maps.h>
deba@1018
    28
#include <lemon/concept_check.h>
deba@1018
    29
#include <lemon/core.h>
ggab90@1130
    30
#include <lemon/bits/stl_iterators.h>
deba@1018
    31
deba@1018
    32
namespace lemon {
deba@1018
    33
  namespace concepts {
deba@1018
    34
deba@1018
    35
    /// \ingroup graph_concepts
deba@1018
    36
    ///
deba@1018
    37
    /// \brief Class describing the concept of undirected bipartite graphs.
deba@1018
    38
    ///
deba@1018
    39
    /// This class describes the common interface of all undirected
deba@1018
    40
    /// bipartite graphs.
deba@1018
    41
    ///
deba@1018
    42
    /// Like all concept classes, it only provides an interface
deba@1018
    43
    /// without any sensible implementation. So any general algorithm for
deba@1018
    44
    /// undirected bipartite graphs should compile with this class,
deba@1018
    45
    /// but it will not run properly, of course.
deba@1018
    46
    /// An actual graph implementation like \ref ListBpGraph or
deba@1018
    47
    /// \ref SmartBpGraph may have additional functionality.
deba@1018
    48
    ///
deba@1018
    49
    /// The bipartite graphs also fulfill the concept of \ref Graph
deba@1018
    50
    /// "undirected graphs". Bipartite graphs provide a bipartition of
deba@1018
    51
    /// the node set, namely a red and blue set of the nodes. The
deba@1026
    52
    /// nodes can be iterated with the RedNodeIt and BlueNodeIt in the
deba@1026
    53
    /// two node sets. With RedNodeMap and BlueNodeMap values can be
deba@1026
    54
    /// assigned to the nodes in the two sets.
deba@1018
    55
    ///
deba@1018
    56
    /// The edges of the graph cannot connect two nodes of the same
deba@1018
    57
    /// set. The edges inherent orientation is from the red nodes to
deba@1018
    58
    /// the blue nodes.
deba@1018
    59
    ///
deba@1018
    60
    /// \sa Graph
deba@1018
    61
    class BpGraph {
deba@1018
    62
    private:
deba@1018
    63
      /// BpGraphs are \e not copy constructible. Use bpGraphCopy instead.
deba@1018
    64
      BpGraph(const BpGraph&) {}
deba@1018
    65
      /// \brief Assignment of a graph to another one is \e not allowed.
deba@1018
    66
      /// Use bpGraphCopy instead.
deba@1018
    67
      void operator=(const BpGraph&) {}
deba@1018
    68
deba@1018
    69
    public:
deba@1018
    70
      /// Default constructor.
deba@1018
    71
      BpGraph() {}
deba@1018
    72
deba@1018
    73
      /// \brief Undirected graphs should be tagged with \c UndirectedTag.
deba@1018
    74
      ///
deba@1018
    75
      /// Undirected graphs should be tagged with \c UndirectedTag.
deba@1018
    76
      ///
deba@1018
    77
      /// This tag helps the \c enable_if technics to make compile time
deba@1018
    78
      /// specializations for undirected graphs.
deba@1018
    79
      typedef True UndirectedTag;
deba@1018
    80
deba@1018
    81
      /// The node type of the graph
deba@1018
    82
deba@1018
    83
      /// This class identifies a node of the graph. It also serves
deba@1018
    84
      /// as a base class of the node iterators,
deba@1018
    85
      /// thus they convert to this type.
deba@1018
    86
      class Node {
deba@1018
    87
      public:
deba@1018
    88
        /// Default constructor
deba@1018
    89
deba@1018
    90
        /// Default constructor.
deba@1018
    91
        /// \warning It sets the object to an undefined value.
deba@1018
    92
        Node() { }
deba@1018
    93
        /// Copy constructor.
deba@1018
    94
deba@1018
    95
        /// Copy constructor.
deba@1018
    96
        ///
deba@1018
    97
        Node(const Node&) { }
alpar@1210
    98
        /// Assignment operator
alpar@1210
    99
alpar@1210
   100
        /// Assignment operator.
alpar@1210
   101
        ///
alpar@1210
   102
        const Node &operator=(const Node&) { return *this; }
deba@1018
   103
deba@1018
   104
        /// %Invalid constructor \& conversion.
deba@1018
   105
deba@1018
   106
        /// Initializes the object to be invalid.
deba@1018
   107
        /// \sa Invalid for more details.
deba@1018
   108
        Node(Invalid) { }
deba@1018
   109
        /// Equality operator
deba@1018
   110
deba@1018
   111
        /// Equality operator.
deba@1018
   112
        ///
deba@1018
   113
        /// Two iterators are equal if and only if they point to the
deba@1018
   114
        /// same object or both are \c INVALID.
deba@1018
   115
        bool operator==(Node) const { return true; }
deba@1018
   116
deba@1018
   117
        /// Inequality operator
deba@1018
   118
deba@1018
   119
        /// Inequality operator.
deba@1018
   120
        bool operator!=(Node) const { return true; }
deba@1018
   121
deba@1018
   122
        /// Artificial ordering operator.
deba@1018
   123
deba@1018
   124
        /// Artificial ordering operator.
deba@1018
   125
        ///
deba@1018
   126
        /// \note This operator only has to define some strict ordering of
deba@1018
   127
        /// the items; this order has nothing to do with the iteration
deba@1018
   128
        /// ordering of the items.
deba@1018
   129
        bool operator<(Node) const { return false; }
deba@1018
   130
deba@1018
   131
      };
deba@1018
   132
deba@1018
   133
      /// Class to represent red nodes.
deba@1018
   134
deba@1018
   135
      /// This class represents the red nodes of the graph. It does
deba@1018
   136
      /// not supposed to be used directly, because the nodes can be
deba@1018
   137
      /// represented as Node instances. This class can be used as
deba@1018
   138
      /// template parameter for special map classes.
deba@1018
   139
      class RedNode : public Node {
deba@1018
   140
      public:
deba@1018
   141
        /// Default constructor
deba@1018
   142
deba@1018
   143
        /// Default constructor.
deba@1018
   144
        /// \warning It sets the object to an undefined value.
deba@1018
   145
        RedNode() { }
deba@1018
   146
        /// Copy constructor.
deba@1018
   147
deba@1018
   148
        /// Copy constructor.
deba@1018
   149
        ///
deba@1018
   150
        RedNode(const RedNode&) : Node() { }
alpar@1210
   151
        /// Assignment operator
alpar@1210
   152
alpar@1210
   153
        /// Assignment operator.
alpar@1210
   154
        ///
alpar@1210
   155
        const RedNode &operator=(const RedNode&) { return *this; }
deba@1018
   156
deba@1018
   157
        /// %Invalid constructor \& conversion.
deba@1018
   158
deba@1018
   159
        /// Initializes the object to be invalid.
deba@1018
   160
        /// \sa Invalid for more details.
deba@1018
   161
        RedNode(Invalid) { }
deba@1018
   162
deba@1018
   163
      };
deba@1018
   164
deba@1018
   165
      /// Class to represent blue nodes.
deba@1018
   166
deba@1018
   167
      /// This class represents the blue nodes of the graph. It does
deba@1018
   168
      /// not supposed to be used directly, because the nodes can be
deba@1018
   169
      /// represented as Node instances. This class can be used as
deba@1018
   170
      /// template parameter for special map classes.
deba@1018
   171
      class BlueNode : public Node {
deba@1018
   172
      public:
deba@1018
   173
        /// Default constructor
deba@1018
   174
deba@1018
   175
        /// Default constructor.
deba@1018
   176
        /// \warning It sets the object to an undefined value.
deba@1018
   177
        BlueNode() { }
deba@1018
   178
        /// Copy constructor.
deba@1018
   179
deba@1018
   180
        /// Copy constructor.
deba@1018
   181
        ///
deba@1018
   182
        BlueNode(const BlueNode&) : Node() { }
alpar@1210
   183
        /// Assignment operator
alpar@1210
   184
alpar@1210
   185
        /// Assignment operator.
alpar@1210
   186
        ///
alpar@1210
   187
        const BlueNode &operator=(const BlueNode&) { return *this; }
alpar@1210
   188
deba@1018
   189
deba@1018
   190
        /// %Invalid constructor \& conversion.
deba@1018
   191
deba@1018
   192
        /// Initializes the object to be invalid.
deba@1018
   193
        /// \sa Invalid for more details.
deba@1018
   194
        BlueNode(Invalid) { }
deba@1018
   195
deba@1018
   196
      };
deba@1018
   197
deba@1018
   198
      /// Iterator class for the red nodes.
deba@1018
   199
deba@1018
   200
      /// This iterator goes through each red node of the graph.
deba@1018
   201
      /// Its usage is quite simple, for example, you can count the number
deba@1018
   202
      /// of red nodes in a graph \c g of type \c %BpGraph like this:
deba@1018
   203
      ///\code
deba@1018
   204
      /// int count=0;
deba@1018
   205
      /// for (BpGraph::RedNodeIt n(g); n!=INVALID; ++n) ++count;
deba@1018
   206
      ///\endcode
deba@1026
   207
      class RedNodeIt : public RedNode {
deba@1018
   208
      public:
deba@1018
   209
        /// Default constructor
deba@1018
   210
deba@1018
   211
        /// Default constructor.
deba@1018
   212
        /// \warning It sets the iterator to an undefined value.
deba@1026
   213
        RedNodeIt() { }
deba@1018
   214
        /// Copy constructor.
deba@1018
   215
deba@1018
   216
        /// Copy constructor.
deba@1018
   217
        ///
deba@1026
   218
        RedNodeIt(const RedNodeIt& n) : RedNode(n) { }
alpar@1210
   219
        /// Assignment operator
alpar@1210
   220
alpar@1210
   221
        /// Assignment operator.
alpar@1210
   222
        ///
alpar@1210
   223
        const RedNodeIt &operator=(const RedNodeIt&) { return *this; }
deba@1018
   224
        /// %Invalid constructor \& conversion.
deba@1018
   225
deba@1018
   226
        /// Initializes the iterator to be invalid.
deba@1018
   227
        /// \sa Invalid for more details.
deba@1026
   228
        RedNodeIt(Invalid) { }
deba@1018
   229
        /// Sets the iterator to the first red node.
deba@1018
   230
deba@1018
   231
        /// Sets the iterator to the first red node of the given
deba@1018
   232
        /// digraph.
deba@1026
   233
        explicit RedNodeIt(const BpGraph&) { }
deba@1018
   234
        /// Sets the iterator to the given red node.
deba@1018
   235
deba@1018
   236
        /// Sets the iterator to the given red node of the given
deba@1018
   237
        /// digraph.
deba@1026
   238
        RedNodeIt(const BpGraph&, const RedNode&) { }
deba@1018
   239
        /// Next node.
deba@1018
   240
deba@1018
   241
        /// Assign the iterator to the next red node.
deba@1018
   242
        ///
deba@1026
   243
        RedNodeIt& operator++() { return *this; }
deba@1018
   244
      };
deba@1018
   245
ggab90@1130
   246
      /// \brief Gets the collection of the red nodes of the graph.
ggab90@1130
   247
      ///
ggab90@1130
   248
      /// This function can be used for iterating on
ggab90@1130
   249
      /// the red nodes of the graph. It returns a wrapped RedNodeIt,
ggab90@1130
   250
      /// which looks like an STL container (by having begin() and end())
ggab90@1130
   251
      /// which you can use in range-based for loops, stl algorithms, etc.
ggab90@1130
   252
      /// For example if g is a BpGraph, you can write:
ggab90@1130
   253
      ///\code
ggab90@1130
   254
      /// for(auto v: g.redNodes())
ggab90@1130
   255
      ///   doSomething(v);
ggab90@1130
   256
      ///\endcode
ggab90@1130
   257
      LemonRangeWrapper1<RedNodeIt, BpGraph> redNodes() const {
ggab90@1130
   258
        return LemonRangeWrapper1<RedNodeIt, BpGraph>(*this);
ggab90@1130
   259
      }
ggab90@1130
   260
ggab90@1130
   261
deba@1018
   262
      /// Iterator class for the blue nodes.
deba@1018
   263
deba@1018
   264
      /// This iterator goes through each blue node of the graph.
deba@1018
   265
      /// Its usage is quite simple, for example, you can count the number
deba@1018
   266
      /// of blue nodes in a graph \c g of type \c %BpGraph like this:
deba@1018
   267
      ///\code
deba@1018
   268
      /// int count=0;
deba@1018
   269
      /// for (BpGraph::BlueNodeIt n(g); n!=INVALID; ++n) ++count;
deba@1018
   270
      ///\endcode
deba@1026
   271
      class BlueNodeIt : public BlueNode {
deba@1018
   272
      public:
deba@1018
   273
        /// Default constructor
deba@1018
   274
deba@1018
   275
        /// Default constructor.
deba@1018
   276
        /// \warning It sets the iterator to an undefined value.
deba@1026
   277
        BlueNodeIt() { }
deba@1018
   278
        /// Copy constructor.
deba@1018
   279
deba@1018
   280
        /// Copy constructor.
deba@1018
   281
        ///
deba@1026
   282
        BlueNodeIt(const BlueNodeIt& n) : BlueNode(n) { }
alpar@1210
   283
        /// Assignment operator
alpar@1210
   284
alpar@1210
   285
        /// Assignment operator.
alpar@1210
   286
        ///
alpar@1210
   287
        const BlueNodeIt &operator=(const BlueNodeIt&) { return *this; }
deba@1018
   288
        /// %Invalid constructor \& conversion.
deba@1018
   289
deba@1018
   290
        /// Initializes the iterator to be invalid.
deba@1018
   291
        /// \sa Invalid for more details.
deba@1026
   292
        BlueNodeIt(Invalid) { }
deba@1018
   293
        /// Sets the iterator to the first blue node.
deba@1018
   294
deba@1018
   295
        /// Sets the iterator to the first blue node of the given
deba@1018
   296
        /// digraph.
deba@1026
   297
        explicit BlueNodeIt(const BpGraph&) { }
deba@1018
   298
        /// Sets the iterator to the given blue node.
deba@1018
   299
deba@1018
   300
        /// Sets the iterator to the given blue node of the given
deba@1018
   301
        /// digraph.
deba@1026
   302
        BlueNodeIt(const BpGraph&, const BlueNode&) { }
deba@1018
   303
        /// Next node.
deba@1018
   304
deba@1018
   305
        /// Assign the iterator to the next blue node.
deba@1018
   306
        ///
deba@1026
   307
        BlueNodeIt& operator++() { return *this; }
deba@1018
   308
      };
deba@1018
   309
ggab90@1130
   310
      /// \brief Gets the collection of the blue nodes of the graph.
ggab90@1130
   311
      ///
ggab90@1130
   312
      /// This function can be used for iterating on
ggab90@1130
   313
      /// the blue nodes of the graph. It returns a wrapped BlueNodeIt,
ggab90@1130
   314
      /// which looks like an STL container (by having begin() and end())
ggab90@1130
   315
      /// which you can use in range-based for loops, stl algorithms, etc.
ggab90@1130
   316
      /// For example if g is a BpGraph, you can write:
ggab90@1130
   317
      ///\code
ggab90@1130
   318
      /// for(auto v: g.blueNodes())
ggab90@1130
   319
      ///   doSomething(v);
ggab90@1130
   320
      ///\endcode
ggab90@1130
   321
      LemonRangeWrapper1<BlueNodeIt, BpGraph> blueNodes() const {
ggab90@1130
   322
        return LemonRangeWrapper1<BlueNodeIt, BpGraph>(*this);
ggab90@1130
   323
      }
ggab90@1130
   324
ggab90@1130
   325
deba@1018
   326
      /// Iterator class for the nodes.
deba@1018
   327
deba@1018
   328
      /// This iterator goes through each node of the graph.
deba@1018
   329
      /// Its usage is quite simple, for example, you can count the number
deba@1018
   330
      /// of nodes in a graph \c g of type \c %BpGraph like this:
deba@1018
   331
      ///\code
deba@1018
   332
      /// int count=0;
deba@1018
   333
      /// for (BpGraph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@1018
   334
      ///\endcode
deba@1018
   335
      class NodeIt : public Node {
deba@1018
   336
      public:
deba@1018
   337
        /// Default constructor
deba@1018
   338
deba@1018
   339
        /// Default constructor.
deba@1018
   340
        /// \warning It sets the iterator to an undefined value.
deba@1018
   341
        NodeIt() { }
deba@1018
   342
        /// Copy constructor.
deba@1018
   343
deba@1018
   344
        /// Copy constructor.
deba@1018
   345
        ///
deba@1018
   346
        NodeIt(const NodeIt& n) : Node(n) { }
alpar@1210
   347
        /// Assignment operator
alpar@1210
   348
alpar@1210
   349
        /// Assignment operator.
alpar@1210
   350
        ///
alpar@1210
   351
        const NodeIt &operator=(const NodeIt&) { return *this; }
deba@1018
   352
        /// %Invalid constructor \& conversion.
deba@1018
   353
deba@1018
   354
        /// Initializes the iterator to be invalid.
deba@1018
   355
        /// \sa Invalid for more details.
deba@1018
   356
        NodeIt(Invalid) { }
deba@1018
   357
        /// Sets the iterator to the first node.
deba@1018
   358
deba@1018
   359
        /// Sets the iterator to the first node of the given digraph.
deba@1018
   360
        ///
deba@1018
   361
        explicit NodeIt(const BpGraph&) { }
deba@1018
   362
        /// Sets the iterator to the given node.
deba@1018
   363
deba@1018
   364
        /// Sets the iterator to the given node of the given digraph.
deba@1018
   365
        ///
deba@1018
   366
        NodeIt(const BpGraph&, const Node&) { }
deba@1018
   367
        /// Next node.
deba@1018
   368
deba@1018
   369
        /// Assign the iterator to the next node.
deba@1018
   370
        ///
deba@1018
   371
        NodeIt& operator++() { return *this; }
deba@1018
   372
      };
deba@1018
   373
ggab90@1130
   374
      /// \brief Gets the collection of the nodes of the graph.
ggab90@1130
   375
      ///
ggab90@1130
   376
      /// This function can be used for iterating on
ggab90@1130
   377
      /// the nodes of the graph. It returns a wrapped NodeIt,
ggab90@1130
   378
      /// which looks like an STL container (by having begin() and end())
ggab90@1130
   379
      /// which you can use in range-based for loops, stl algorithms, etc.
ggab90@1130
   380
      /// For example if g is a BpGraph, you can write:
ggab90@1130
   381
      ///\code
ggab90@1130
   382
      /// for(auto v: g.nodes())
ggab90@1130
   383
      ///   doSomething(v);
ggab90@1130
   384
      ///\endcode
ggab90@1130
   385
      LemonRangeWrapper1<NodeIt, BpGraph> nodes() const {
ggab90@1130
   386
        return LemonRangeWrapper1<NodeIt, BpGraph>(*this);
ggab90@1130
   387
      }
ggab90@1130
   388
ggab90@1130
   389
deba@1018
   390
deba@1018
   391
      /// The edge type of the graph
deba@1018
   392
deba@1018
   393
      /// This class identifies an edge of the graph. It also serves
deba@1018
   394
      /// as a base class of the edge iterators,
deba@1018
   395
      /// thus they will convert to this type.
deba@1018
   396
      class Edge {
deba@1018
   397
      public:
deba@1018
   398
        /// Default constructor
deba@1018
   399
deba@1018
   400
        /// Default constructor.
deba@1018
   401
        /// \warning It sets the object to an undefined value.
deba@1018
   402
        Edge() { }
deba@1018
   403
        /// Copy constructor.
deba@1018
   404
deba@1018
   405
        /// Copy constructor.
deba@1018
   406
        ///
deba@1018
   407
        Edge(const Edge&) { }
alpar@1210
   408
        /// Assignment operator
alpar@1210
   409
alpar@1210
   410
        /// Assignment operator.
alpar@1210
   411
        ///
alpar@1210
   412
        const Edge &operator=(const Edge&) { return *this; }
deba@1018
   413
        /// %Invalid constructor \& conversion.
deba@1018
   414
deba@1018
   415
        /// Initializes the object to be invalid.
deba@1018
   416
        /// \sa Invalid for more details.
deba@1018
   417
        Edge(Invalid) { }
deba@1018
   418
        /// Equality operator
deba@1018
   419
deba@1018
   420
        /// Equality operator.
deba@1018
   421
        ///
deba@1018
   422
        /// Two iterators are equal if and only if they point to the
deba@1018
   423
        /// same object or both are \c INVALID.
deba@1018
   424
        bool operator==(Edge) const { return true; }
deba@1018
   425
        /// Inequality operator
deba@1018
   426
deba@1018
   427
        /// Inequality operator.
deba@1018
   428
        bool operator!=(Edge) const { return true; }
deba@1018
   429
deba@1018
   430
        /// Artificial ordering operator.
deba@1018
   431
deba@1018
   432
        /// Artificial ordering operator.
deba@1018
   433
        ///
deba@1018
   434
        /// \note This operator only has to define some strict ordering of
deba@1018
   435
        /// the edges; this order has nothing to do with the iteration
deba@1018
   436
        /// ordering of the edges.
deba@1018
   437
        bool operator<(Edge) const { return false; }
deba@1018
   438
      };
deba@1018
   439
deba@1018
   440
      /// Iterator class for the edges.
deba@1018
   441
deba@1018
   442
      /// This iterator goes through each edge of the graph.
deba@1018
   443
      /// Its usage is quite simple, for example, you can count the number
deba@1018
   444
      /// of edges in a graph \c g of type \c %BpGraph as follows:
deba@1018
   445
      ///\code
deba@1018
   446
      /// int count=0;
deba@1018
   447
      /// for(BpGraph::EdgeIt e(g); e!=INVALID; ++e) ++count;
deba@1018
   448
      ///\endcode
deba@1018
   449
      class EdgeIt : public Edge {
deba@1018
   450
      public:
deba@1018
   451
        /// Default constructor
deba@1018
   452
deba@1018
   453
        /// Default constructor.
deba@1018
   454
        /// \warning It sets the iterator to an undefined value.
deba@1018
   455
        EdgeIt() { }
deba@1018
   456
        /// Copy constructor.
deba@1018
   457
deba@1018
   458
        /// Copy constructor.
deba@1018
   459
        ///
deba@1018
   460
        EdgeIt(const EdgeIt& e) : Edge(e) { }
alpar@1210
   461
        /// Assignment operator
alpar@1210
   462
alpar@1210
   463
        /// Assignment operator.
alpar@1210
   464
        ///
alpar@1210
   465
        const EdgeIt &operator=(const EdgeIt&) { return *this; }
deba@1018
   466
        /// %Invalid constructor \& conversion.
deba@1018
   467
deba@1018
   468
        /// Initializes the iterator to be invalid.
deba@1018
   469
        /// \sa Invalid for more details.
deba@1018
   470
        EdgeIt(Invalid) { }
deba@1018
   471
        /// Sets the iterator to the first edge.
deba@1018
   472
deba@1018
   473
        /// Sets the iterator to the first edge of the given graph.
deba@1018
   474
        ///
deba@1018
   475
        explicit EdgeIt(const BpGraph&) { }
deba@1018
   476
        /// Sets the iterator to the given edge.
deba@1018
   477
deba@1018
   478
        /// Sets the iterator to the given edge of the given graph.
deba@1018
   479
        ///
deba@1018
   480
        EdgeIt(const BpGraph&, const Edge&) { }
deba@1018
   481
        /// Next edge
deba@1018
   482
deba@1018
   483
        /// Assign the iterator to the next edge.
deba@1018
   484
        ///
deba@1018
   485
        EdgeIt& operator++() { return *this; }
deba@1018
   486
      };
deba@1018
   487
ggab90@1130
   488
      /// \brief Gets the collection of the edges of the graph.
ggab90@1130
   489
      ///
ggab90@1130
   490
      /// This function can be used for iterating on the
ggab90@1130
   491
      /// edges of the graph. It returns a wrapped
ggab90@1130
   492
      /// EdgeIt, which looks like an STL container
ggab90@1130
   493
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   494
      /// for loops, stl algorithms, etc.
ggab90@1130
   495
      /// For example if g is a BpGraph, you can write:
ggab90@1130
   496
      ///\code
ggab90@1130
   497
      /// for(auto e: g.edges())
ggab90@1130
   498
      ///   doSomething(e);
ggab90@1130
   499
      ///\endcode
ggab90@1130
   500
      LemonRangeWrapper1<EdgeIt, BpGraph> edges() const {
ggab90@1130
   501
        return LemonRangeWrapper1<EdgeIt, BpGraph>(*this);
ggab90@1130
   502
      }
ggab90@1130
   503
ggab90@1130
   504
deba@1018
   505
      /// Iterator class for the incident edges of a node.
deba@1018
   506
deba@1018
   507
      /// This iterator goes trough the incident undirected edges
deba@1018
   508
      /// of a certain node of a graph.
deba@1018
   509
      /// Its usage is quite simple, for example, you can compute the
deba@1018
   510
      /// degree (i.e. the number of incident edges) of a node \c n
deba@1018
   511
      /// in a graph \c g of type \c %BpGraph as follows.
deba@1018
   512
      ///
deba@1018
   513
      ///\code
deba@1018
   514
      /// int count=0;
deba@1018
   515
      /// for(BpGraph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1018
   516
      ///\endcode
deba@1018
   517
      ///
deba@1018
   518
      /// \warning Loop edges will be iterated twice.
deba@1018
   519
      class IncEdgeIt : public Edge {
deba@1018
   520
      public:
deba@1018
   521
        /// Default constructor
deba@1018
   522
deba@1018
   523
        /// Default constructor.
deba@1018
   524
        /// \warning It sets the iterator to an undefined value.
deba@1018
   525
        IncEdgeIt() { }
deba@1018
   526
        /// Copy constructor.
deba@1018
   527
deba@1018
   528
        /// Copy constructor.
deba@1018
   529
        ///
deba@1018
   530
        IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
alpar@1210
   531
        /// Assignment operator
alpar@1210
   532
alpar@1210
   533
        /// Assignment operator.
alpar@1210
   534
        ///
alpar@1210
   535
        const IncEdgeIt &operator=(const IncEdgeIt&) { return *this; }
deba@1018
   536
        /// %Invalid constructor \& conversion.
deba@1018
   537
deba@1018
   538
        /// Initializes the iterator to be invalid.
deba@1018
   539
        /// \sa Invalid for more details.
deba@1018
   540
        IncEdgeIt(Invalid) { }
deba@1018
   541
        /// Sets the iterator to the first incident edge.
deba@1018
   542
deba@1018
   543
        /// Sets the iterator to the first incident edge of the given node.
deba@1018
   544
        ///
deba@1018
   545
        IncEdgeIt(const BpGraph&, const Node&) { }
deba@1018
   546
        /// Sets the iterator to the given edge.
deba@1018
   547
deba@1018
   548
        /// Sets the iterator to the given edge of the given graph.
deba@1018
   549
        ///
deba@1018
   550
        IncEdgeIt(const BpGraph&, const Edge&) { }
deba@1018
   551
        /// Next incident edge
deba@1018
   552
deba@1018
   553
        /// Assign the iterator to the next incident edge
deba@1018
   554
        /// of the corresponding node.
deba@1018
   555
        IncEdgeIt& operator++() { return *this; }
deba@1018
   556
      };
deba@1018
   557
ggab90@1130
   558
      /// \brief Gets the collection of the incident edges
ggab90@1130
   559
      ///  of a certain node of the graph.
ggab90@1130
   560
      ///
ggab90@1130
   561
      /// This function can be used for iterating on the
ggab90@1130
   562
      /// incident undirected edges of a certain node of the graph.
ggab90@1130
   563
      /// It returns a wrapped
ggab90@1130
   564
      /// IncEdgeIt, which looks like an STL container
ggab90@1130
   565
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   566
      /// for loops, stl algorithms, etc.
ggab90@1130
   567
      /// For example if g is a BpGraph and u is a Node, you can write:
ggab90@1130
   568
      ///\code
ggab90@1130
   569
      /// for(auto e: g.incEdges(u))
ggab90@1130
   570
      ///   doSomething(e);
ggab90@1130
   571
      ///\endcode
ggab90@1130
   572
      LemonRangeWrapper2<IncEdgeIt, BpGraph, Node> incEdges(const Node& u) const {
ggab90@1130
   573
        return LemonRangeWrapper2<IncEdgeIt, BpGraph, Node>(*this, u);
ggab90@1130
   574
      }
ggab90@1130
   575
ggab90@1130
   576
deba@1018
   577
      /// The arc type of the graph
deba@1018
   578
deba@1018
   579
      /// This class identifies a directed arc of the graph. It also serves
deba@1018
   580
      /// as a base class of the arc iterators,
deba@1018
   581
      /// thus they will convert to this type.
deba@1018
   582
      class Arc {
deba@1018
   583
      public:
deba@1018
   584
        /// Default constructor
deba@1018
   585
deba@1018
   586
        /// Default constructor.
deba@1018
   587
        /// \warning It sets the object to an undefined value.
deba@1018
   588
        Arc() { }
deba@1018
   589
        /// Copy constructor.
deba@1018
   590
deba@1018
   591
        /// Copy constructor.
deba@1018
   592
        ///
deba@1018
   593
        Arc(const Arc&) { }
alpar@1210
   594
        /// Assignment operator
alpar@1210
   595
alpar@1210
   596
        /// Assignment operator.
alpar@1210
   597
        ///
alpar@1210
   598
        const Arc &operator=(const Arc&) { return *this; }
deba@1018
   599
        /// %Invalid constructor \& conversion.
deba@1018
   600
deba@1018
   601
        /// Initializes the object to be invalid.
deba@1018
   602
        /// \sa Invalid for more details.
deba@1018
   603
        Arc(Invalid) { }
deba@1018
   604
        /// Equality operator
deba@1018
   605
deba@1018
   606
        /// Equality operator.
deba@1018
   607
        ///
deba@1018
   608
        /// Two iterators are equal if and only if they point to the
deba@1018
   609
        /// same object or both are \c INVALID.
deba@1018
   610
        bool operator==(Arc) const { return true; }
deba@1018
   611
        /// Inequality operator
deba@1018
   612
deba@1018
   613
        /// Inequality operator.
deba@1018
   614
        bool operator!=(Arc) const { return true; }
deba@1018
   615
deba@1018
   616
        /// Artificial ordering operator.
deba@1018
   617
deba@1018
   618
        /// Artificial ordering operator.
deba@1018
   619
        ///
deba@1018
   620
        /// \note This operator only has to define some strict ordering of
deba@1018
   621
        /// the arcs; this order has nothing to do with the iteration
deba@1018
   622
        /// ordering of the arcs.
deba@1018
   623
        bool operator<(Arc) const { return false; }
deba@1018
   624
deba@1018
   625
        /// Converison to \c Edge
deba@1018
   626
deba@1018
   627
        /// Converison to \c Edge.
deba@1018
   628
        ///
deba@1018
   629
        operator Edge() const { return Edge(); }
deba@1018
   630
      };
deba@1018
   631
deba@1018
   632
      /// Iterator class for the arcs.
deba@1018
   633
deba@1018
   634
      /// This iterator goes through each directed arc of the graph.
deba@1018
   635
      /// Its usage is quite simple, for example, you can count the number
deba@1018
   636
      /// of arcs in a graph \c g of type \c %BpGraph as follows:
deba@1018
   637
      ///\code
deba@1018
   638
      /// int count=0;
deba@1018
   639
      /// for(BpGraph::ArcIt a(g); a!=INVALID; ++a) ++count;
deba@1018
   640
      ///\endcode
deba@1018
   641
      class ArcIt : public Arc {
deba@1018
   642
      public:
deba@1018
   643
        /// Default constructor
deba@1018
   644
deba@1018
   645
        /// Default constructor.
deba@1018
   646
        /// \warning It sets the iterator to an undefined value.
deba@1018
   647
        ArcIt() { }
deba@1018
   648
        /// Copy constructor.
deba@1018
   649
deba@1018
   650
        /// Copy constructor.
deba@1018
   651
        ///
deba@1018
   652
        ArcIt(const ArcIt& e) : Arc(e) { }
alpar@1210
   653
        /// Assignment operator
alpar@1210
   654
alpar@1210
   655
        /// Assignment operator.
alpar@1210
   656
        ///
alpar@1210
   657
        const ArcIt &operator=(const ArcIt&) { return *this; }
deba@1018
   658
        /// %Invalid constructor \& conversion.
deba@1018
   659
deba@1018
   660
        /// Initializes the iterator to be invalid.
deba@1018
   661
        /// \sa Invalid for more details.
deba@1018
   662
        ArcIt(Invalid) { }
deba@1018
   663
        /// Sets the iterator to the first arc.
deba@1018
   664
deba@1018
   665
        /// Sets the iterator to the first arc of the given graph.
deba@1018
   666
        ///
alpar@1087
   667
        explicit ArcIt(const BpGraph &g)
alpar@1087
   668
        {
alpar@1087
   669
          ::lemon::ignore_unused_variable_warning(g);
alpar@1087
   670
        }
deba@1018
   671
        /// Sets the iterator to the given arc.
deba@1018
   672
deba@1018
   673
        /// Sets the iterator to the given arc of the given graph.
deba@1018
   674
        ///
deba@1018
   675
        ArcIt(const BpGraph&, const Arc&) { }
deba@1018
   676
        /// Next arc
deba@1018
   677
deba@1018
   678
        /// Assign the iterator to the next arc.
deba@1018
   679
        ///
deba@1018
   680
        ArcIt& operator++() { return *this; }
deba@1018
   681
      };
deba@1018
   682
ggab90@1130
   683
      /// \brief Gets the collection of the directed arcs of the graph.
ggab90@1130
   684
      ///
ggab90@1130
   685
      /// This function can be used for iterating on the
ggab90@1130
   686
      /// arcs of the graph. It returns a wrapped
ggab90@1130
   687
      /// ArcIt, which looks like an STL container
ggab90@1130
   688
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   689
      /// for loops, stl algorithms, etc.
ggab90@1130
   690
      /// For example if g is a BpGraph you can write:
ggab90@1130
   691
      ///\code
ggab90@1130
   692
      /// for(auto a: g.arcs())
ggab90@1130
   693
      ///   doSomething(a);
ggab90@1130
   694
      ///\endcode
ggab90@1130
   695
      LemonRangeWrapper1<ArcIt, BpGraph> arcs() const {
ggab90@1130
   696
        return LemonRangeWrapper1<ArcIt, BpGraph>(*this);
ggab90@1130
   697
      }
ggab90@1130
   698
ggab90@1130
   699
deba@1018
   700
      /// Iterator class for the outgoing arcs of a node.
deba@1018
   701
deba@1018
   702
      /// This iterator goes trough the \e outgoing directed arcs of a
deba@1018
   703
      /// certain node of a graph.
deba@1018
   704
      /// Its usage is quite simple, for example, you can count the number
deba@1018
   705
      /// of outgoing arcs of a node \c n
deba@1018
   706
      /// in a graph \c g of type \c %BpGraph as follows.
deba@1018
   707
      ///\code
deba@1018
   708
      /// int count=0;
deba@1018
   709
      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
deba@1018
   710
      ///\endcode
deba@1018
   711
      class OutArcIt : public Arc {
deba@1018
   712
      public:
deba@1018
   713
        /// Default constructor
deba@1018
   714
deba@1018
   715
        /// Default constructor.
deba@1018
   716
        /// \warning It sets the iterator to an undefined value.
deba@1018
   717
        OutArcIt() { }
deba@1018
   718
        /// Copy constructor.
deba@1018
   719
deba@1018
   720
        /// Copy constructor.
deba@1018
   721
        ///
deba@1018
   722
        OutArcIt(const OutArcIt& e) : Arc(e) { }
alpar@1210
   723
        /// Assignment operator
alpar@1210
   724
alpar@1210
   725
        /// Assignment operator.
alpar@1210
   726
        ///
alpar@1210
   727
        const OutArcIt &operator=(const OutArcIt&) { return *this; }
deba@1018
   728
        /// %Invalid constructor \& conversion.
deba@1018
   729
deba@1018
   730
        /// Initializes the iterator to be invalid.
deba@1018
   731
        /// \sa Invalid for more details.
deba@1018
   732
        OutArcIt(Invalid) { }
deba@1018
   733
        /// Sets the iterator to the first outgoing arc.
deba@1018
   734
deba@1018
   735
        /// Sets the iterator to the first outgoing arc of the given node.
deba@1018
   736
        ///
deba@1018
   737
        OutArcIt(const BpGraph& n, const Node& g) {
alpar@1087
   738
          ::lemon::ignore_unused_variable_warning(n);
alpar@1087
   739
          ::lemon::ignore_unused_variable_warning(g);
deba@1018
   740
        }
deba@1018
   741
        /// Sets the iterator to the given arc.
deba@1018
   742
deba@1018
   743
        /// Sets the iterator to the given arc of the given graph.
deba@1018
   744
        ///
deba@1018
   745
        OutArcIt(const BpGraph&, const Arc&) { }
deba@1018
   746
        /// Next outgoing arc
deba@1018
   747
deba@1018
   748
        /// Assign the iterator to the next
deba@1018
   749
        /// outgoing arc of the corresponding node.
deba@1018
   750
        OutArcIt& operator++() { return *this; }
deba@1018
   751
      };
deba@1018
   752
ggab90@1130
   753
      /// \brief Gets the collection of the outgoing directed arcs of a
ggab90@1130
   754
      /// certain node of the graph.
ggab90@1130
   755
      ///
ggab90@1130
   756
      /// This function can be used for iterating on the
ggab90@1130
   757
      /// outgoing arcs of a certain node of the graph. It returns a wrapped
ggab90@1130
   758
      /// OutArcIt, which looks like an STL container
ggab90@1130
   759
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   760
      /// for loops, stl algorithms, etc.
ggab90@1130
   761
      /// For example if g is a BpGraph and u is a Node, you can write:
ggab90@1130
   762
      ///\code
ggab90@1130
   763
      /// for(auto a: g.outArcs(u))
ggab90@1130
   764
      ///   doSomething(a);
ggab90@1130
   765
      ///\endcode
ggab90@1130
   766
      LemonRangeWrapper2<OutArcIt, BpGraph, Node> outArcs(const Node& u) const {
ggab90@1130
   767
        return LemonRangeWrapper2<OutArcIt, BpGraph, Node>(*this, u);
ggab90@1130
   768
      }
ggab90@1130
   769
ggab90@1130
   770
deba@1018
   771
      /// Iterator class for the incoming arcs of a node.
deba@1018
   772
deba@1018
   773
      /// This iterator goes trough the \e incoming directed arcs of a
deba@1018
   774
      /// certain node of a graph.
deba@1018
   775
      /// Its usage is quite simple, for example, you can count the number
deba@1018
   776
      /// of incoming arcs of a node \c n
deba@1018
   777
      /// in a graph \c g of type \c %BpGraph as follows.
deba@1018
   778
      ///\code
deba@1018
   779
      /// int count=0;
deba@1018
   780
      /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
deba@1018
   781
      ///\endcode
deba@1018
   782
      class InArcIt : public Arc {
deba@1018
   783
      public:
deba@1018
   784
        /// Default constructor
deba@1018
   785
deba@1018
   786
        /// Default constructor.
deba@1018
   787
        /// \warning It sets the iterator to an undefined value.
deba@1018
   788
        InArcIt() { }
deba@1018
   789
        /// Copy constructor.
deba@1018
   790
deba@1018
   791
        /// Copy constructor.
deba@1018
   792
        ///
deba@1018
   793
        InArcIt(const InArcIt& e) : Arc(e) { }
alpar@1210
   794
        /// Assignment operator
alpar@1210
   795
alpar@1210
   796
        /// Assignment operator.
alpar@1210
   797
        ///
alpar@1210
   798
        const InArcIt &operator=(const InArcIt&) { return *this; }
deba@1018
   799
        /// %Invalid constructor \& conversion.
deba@1018
   800
deba@1018
   801
        /// Initializes the iterator to be invalid.
deba@1018
   802
        /// \sa Invalid for more details.
deba@1018
   803
        InArcIt(Invalid) { }
deba@1018
   804
        /// Sets the iterator to the first incoming arc.
deba@1018
   805
deba@1018
   806
        /// Sets the iterator to the first incoming arc of the given node.
deba@1018
   807
        ///
deba@1018
   808
        InArcIt(const BpGraph& g, const Node& n) {
alpar@1087
   809
          ::lemon::ignore_unused_variable_warning(n);
alpar@1087
   810
          ::lemon::ignore_unused_variable_warning(g);
deba@1018
   811
        }
deba@1018
   812
        /// Sets the iterator to the given arc.
deba@1018
   813
deba@1018
   814
        /// Sets the iterator to the given arc of the given graph.
deba@1018
   815
        ///
deba@1018
   816
        InArcIt(const BpGraph&, const Arc&) { }
deba@1018
   817
        /// Next incoming arc
deba@1018
   818
deba@1018
   819
        /// Assign the iterator to the next
deba@1018
   820
        /// incoming arc of the corresponding node.
deba@1018
   821
        InArcIt& operator++() { return *this; }
deba@1018
   822
      };
deba@1018
   823
ggab90@1130
   824
      /// \brief Gets the collection of the incoming directed arcs of a
ggab90@1130
   825
      /// certain node of the graph.
ggab90@1130
   826
      ///
ggab90@1130
   827
      /// This function can be used for iterating on the
ggab90@1130
   828
      /// incoming arcs of a certain node of the graph. It returns a wrapped
ggab90@1130
   829
      /// InArcIt, which looks like an STL container
ggab90@1130
   830
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   831
      /// for loops, stl algorithms, etc.
ggab90@1130
   832
      /// For example if g is a BpGraph and u is a Node, you can write:
ggab90@1130
   833
      ///\code
ggab90@1130
   834
      /// for(auto a: g.inArcs(u))
ggab90@1130
   835
      ///   doSomething(a);
ggab90@1130
   836
      ///\endcode
ggab90@1130
   837
      LemonRangeWrapper2<InArcIt, BpGraph, Node> inArcs(const Node& u) const {
ggab90@1130
   838
        return LemonRangeWrapper2<InArcIt, BpGraph, Node>(*this, u);
ggab90@1130
   839
      }
ggab90@1130
   840
ggab90@1130
   841
deba@1018
   842
      /// \brief Standard graph map type for the nodes.
deba@1018
   843
      ///
deba@1018
   844
      /// Standard graph map type for the nodes.
deba@1018
   845
      /// It conforms to the ReferenceMap concept.
deba@1018
   846
      template<class T>
deba@1018
   847
      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
deba@1018
   848
      {
deba@1018
   849
      public:
deba@1018
   850
deba@1018
   851
        /// Constructor
deba@1018
   852
        explicit NodeMap(const BpGraph&) { }
deba@1018
   853
        /// Constructor with given initial value
deba@1018
   854
        NodeMap(const BpGraph&, T) { }
deba@1018
   855
deba@1018
   856
      private:
deba@1018
   857
        ///Copy constructor
deba@1018
   858
        NodeMap(const NodeMap& nm) :
deba@1018
   859
          ReferenceMap<Node, T, T&, const T&>(nm) { }
deba@1018
   860
        ///Assignment operator
deba@1018
   861
        template <typename CMap>
deba@1018
   862
        NodeMap& operator=(const CMap&) {
deba@1018
   863
          checkConcept<ReadMap<Node, T>, CMap>();
deba@1018
   864
          return *this;
deba@1018
   865
        }
deba@1018
   866
      };
deba@1018
   867
deba@1018
   868
      /// \brief Standard graph map type for the red nodes.
deba@1018
   869
      ///
deba@1018
   870
      /// Standard graph map type for the red nodes.
deba@1018
   871
      /// It conforms to the ReferenceMap concept.
deba@1018
   872
      template<class T>
deba@1026
   873
      class RedNodeMap : public ReferenceMap<Node, T, T&, const T&>
deba@1018
   874
      {
deba@1018
   875
      public:
deba@1018
   876
deba@1018
   877
        /// Constructor
deba@1026
   878
        explicit RedNodeMap(const BpGraph&) { }
deba@1018
   879
        /// Constructor with given initial value
deba@1026
   880
        RedNodeMap(const BpGraph&, T) { }
deba@1018
   881
deba@1018
   882
      private:
deba@1018
   883
        ///Copy constructor
deba@1026
   884
        RedNodeMap(const RedNodeMap& nm) :
deba@1018
   885
          ReferenceMap<Node, T, T&, const T&>(nm) { }
deba@1018
   886
        ///Assignment operator
deba@1018
   887
        template <typename CMap>
deba@1026
   888
        RedNodeMap& operator=(const CMap&) {
deba@1018
   889
          checkConcept<ReadMap<Node, T>, CMap>();
deba@1018
   890
          return *this;
deba@1018
   891
        }
deba@1018
   892
      };
deba@1018
   893
deba@1018
   894
      /// \brief Standard graph map type for the blue nodes.
deba@1018
   895
      ///
deba@1018
   896
      /// Standard graph map type for the blue nodes.
deba@1018
   897
      /// It conforms to the ReferenceMap concept.
deba@1018
   898
      template<class T>
deba@1026
   899
      class BlueNodeMap : public ReferenceMap<Node, T, T&, const T&>
deba@1018
   900
      {
deba@1018
   901
      public:
deba@1018
   902
deba@1018
   903
        /// Constructor
deba@1026
   904
        explicit BlueNodeMap(const BpGraph&) { }
deba@1018
   905
        /// Constructor with given initial value
deba@1026
   906
        BlueNodeMap(const BpGraph&, T) { }
deba@1018
   907
deba@1018
   908
      private:
deba@1018
   909
        ///Copy constructor
deba@1026
   910
        BlueNodeMap(const BlueNodeMap& nm) :
deba@1018
   911
          ReferenceMap<Node, T, T&, const T&>(nm) { }
deba@1018
   912
        ///Assignment operator
deba@1018
   913
        template <typename CMap>
deba@1026
   914
        BlueNodeMap& operator=(const CMap&) {
deba@1018
   915
          checkConcept<ReadMap<Node, T>, CMap>();
deba@1018
   916
          return *this;
deba@1018
   917
        }
deba@1018
   918
      };
deba@1018
   919
deba@1018
   920
      /// \brief Standard graph map type for the arcs.
deba@1018
   921
      ///
deba@1018
   922
      /// Standard graph map type for the arcs.
deba@1018
   923
      /// It conforms to the ReferenceMap concept.
deba@1018
   924
      template<class T>
deba@1018
   925
      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
deba@1018
   926
      {
deba@1018
   927
      public:
deba@1018
   928
deba@1018
   929
        /// Constructor
deba@1018
   930
        explicit ArcMap(const BpGraph&) { }
deba@1018
   931
        /// Constructor with given initial value
deba@1018
   932
        ArcMap(const BpGraph&, T) { }
deba@1018
   933
deba@1018
   934
      private:
deba@1018
   935
        ///Copy constructor
deba@1018
   936
        ArcMap(const ArcMap& em) :
deba@1018
   937
          ReferenceMap<Arc, T, T&, const T&>(em) { }
deba@1018
   938
        ///Assignment operator
deba@1018
   939
        template <typename CMap>
deba@1018
   940
        ArcMap& operator=(const CMap&) {
deba@1018
   941
          checkConcept<ReadMap<Arc, T>, CMap>();
deba@1018
   942
          return *this;
deba@1018
   943
        }
deba@1018
   944
      };
deba@1018
   945
deba@1018
   946
      /// \brief Standard graph map type for the edges.
deba@1018
   947
      ///
deba@1018
   948
      /// Standard graph map type for the edges.
deba@1018
   949
      /// It conforms to the ReferenceMap concept.
deba@1018
   950
      template<class T>
deba@1018
   951
      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
deba@1018
   952
      {
deba@1018
   953
      public:
deba@1018
   954
deba@1018
   955
        /// Constructor
deba@1018
   956
        explicit EdgeMap(const BpGraph&) { }
deba@1018
   957
        /// Constructor with given initial value
deba@1018
   958
        EdgeMap(const BpGraph&, T) { }
deba@1018
   959
deba@1018
   960
      private:
deba@1018
   961
        ///Copy constructor
deba@1018
   962
        EdgeMap(const EdgeMap& em) :
deba@1018
   963
          ReferenceMap<Edge, T, T&, const T&>(em) {}
deba@1018
   964
        ///Assignment operator
deba@1018
   965
        template <typename CMap>
deba@1018
   966
        EdgeMap& operator=(const CMap&) {
deba@1018
   967
          checkConcept<ReadMap<Edge, T>, CMap>();
deba@1018
   968
          return *this;
deba@1018
   969
        }
deba@1018
   970
      };
deba@1018
   971
deba@1018
   972
      /// \brief Gives back %true for red nodes.
deba@1018
   973
      ///
deba@1018
   974
      /// Gives back %true for red nodes.
deba@1018
   975
      bool red(const Node&) const { return true; }
deba@1018
   976
deba@1018
   977
      /// \brief Gives back %true for blue nodes.
deba@1018
   978
      ///
deba@1018
   979
      /// Gives back %true for blue nodes.
deba@1018
   980
      bool blue(const Node&) const { return true; }
deba@1018
   981
deba@1025
   982
      /// \brief Converts the node to red node object.
deba@1025
   983
      ///
deba@1028
   984
      /// This function converts unsafely the node to red node
deba@1025
   985
      /// object. It should be called only if the node is from the red
deba@1025
   986
      /// partition or INVALID.
deba@1025
   987
      RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); }
deba@1025
   988
deba@1025
   989
      /// \brief Converts the node to blue node object.
deba@1025
   990
      ///
deba@1028
   991
      /// This function converts unsafely the node to blue node
deba@1025
   992
      /// object. It should be called only if the node is from the red
deba@1025
   993
      /// partition or INVALID.
deba@1025
   994
      BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); }
deba@1025
   995
deba@1025
   996
      /// \brief Converts the node to red node object.
deba@1025
   997
      ///
deba@1028
   998
      /// This function converts safely the node to red node
deba@1025
   999
      /// object. If the node is not from the red partition, then it
deba@1025
  1000
      /// returns INVALID.
deba@1025
  1001
      RedNode asRedNode(const Node&) const { return RedNode(); }
deba@1025
  1002
deba@1025
  1003
      /// \brief Converts the node to blue node object.
deba@1025
  1004
      ///
deba@1028
  1005
      /// This function converts unsafely the node to blue node
deba@1025
  1006
      /// object. If the node is not from the blue partition, then it
deba@1025
  1007
      /// returns INVALID.
deba@1025
  1008
      BlueNode asBlueNode(const Node&) const { return BlueNode(); }
deba@1025
  1009
deba@1018
  1010
      /// \brief Gives back the red end node of the edge.
alpar@1092
  1011
      ///
deba@1018
  1012
      /// Gives back the red end node of the edge.
deba@1025
  1013
      RedNode redNode(const Edge&) const { return RedNode(); }
deba@1018
  1014
deba@1018
  1015
      /// \brief Gives back the blue end node of the edge.
alpar@1092
  1016
      ///
deba@1018
  1017
      /// Gives back the blue end node of the edge.
deba@1025
  1018
      BlueNode blueNode(const Edge&) const { return BlueNode(); }
deba@1018
  1019
deba@1018
  1020
      /// \brief The first node of the edge.
deba@1018
  1021
      ///
deba@1018
  1022
      /// It is a synonim for the \c redNode().
deba@1018
  1023
      Node u(Edge) const { return INVALID; }
deba@1018
  1024
deba@1018
  1025
      /// \brief The second node of the edge.
deba@1018
  1026
      ///
deba@1018
  1027
      /// It is a synonim for the \c blueNode().
deba@1018
  1028
      Node v(Edge) const { return INVALID; }
deba@1018
  1029
deba@1018
  1030
      /// \brief The source node of the arc.
deba@1018
  1031
      ///
deba@1018
  1032
      /// Returns the source node of the given arc.
deba@1018
  1033
      Node source(Arc) const { return INVALID; }
deba@1018
  1034
deba@1018
  1035
      /// \brief The target node of the arc.
deba@1018
  1036
      ///
deba@1018
  1037
      /// Returns the target node of the given arc.
deba@1018
  1038
      Node target(Arc) const { return INVALID; }
deba@1018
  1039
deba@1018
  1040
      /// \brief The ID of the node.
deba@1018
  1041
      ///
deba@1018
  1042
      /// Returns the ID of the given node.
deba@1018
  1043
      int id(Node) const { return -1; }
deba@1018
  1044
deba@1018
  1045
      /// \brief The red ID of the node.
deba@1018
  1046
      ///
deba@1018
  1047
      /// Returns the red ID of the given node.
deba@1018
  1048
      int id(RedNode) const { return -1; }
deba@1018
  1049
deba@1018
  1050
      /// \brief The blue ID of the node.
deba@1018
  1051
      ///
deba@1018
  1052
      /// Returns the blue ID of the given node.
deba@1018
  1053
      int id(BlueNode) const { return -1; }
deba@1018
  1054
deba@1018
  1055
      /// \brief The ID of the edge.
deba@1018
  1056
      ///
deba@1018
  1057
      /// Returns the ID of the given edge.
deba@1018
  1058
      int id(Edge) const { return -1; }
deba@1018
  1059
deba@1018
  1060
      /// \brief The ID of the arc.
deba@1018
  1061
      ///
deba@1018
  1062
      /// Returns the ID of the given arc.
deba@1018
  1063
      int id(Arc) const { return -1; }
deba@1018
  1064
deba@1018
  1065
      /// \brief The node with the given ID.
deba@1018
  1066
      ///
deba@1018
  1067
      /// Returns the node with the given ID.
deba@1018
  1068
      /// \pre The argument should be a valid node ID in the graph.
deba@1018
  1069
      Node nodeFromId(int) const { return INVALID; }
deba@1018
  1070
deba@1018
  1071
      /// \brief The edge with the given ID.
deba@1018
  1072
      ///
deba@1018
  1073
      /// Returns the edge with the given ID.
deba@1018
  1074
      /// \pre The argument should be a valid edge ID in the graph.
deba@1018
  1075
      Edge edgeFromId(int) const { return INVALID; }
deba@1018
  1076
deba@1018
  1077
      /// \brief The arc with the given ID.
deba@1018
  1078
      ///
deba@1018
  1079
      /// Returns the arc with the given ID.
deba@1018
  1080
      /// \pre The argument should be a valid arc ID in the graph.
deba@1018
  1081
      Arc arcFromId(int) const { return INVALID; }
deba@1018
  1082
deba@1018
  1083
      /// \brief An upper bound on the node IDs.
deba@1018
  1084
      ///
deba@1018
  1085
      /// Returns an upper bound on the node IDs.
deba@1018
  1086
      int maxNodeId() const { return -1; }
deba@1018
  1087
deba@1018
  1088
      /// \brief An upper bound on the red IDs.
deba@1018
  1089
      ///
deba@1018
  1090
      /// Returns an upper bound on the red IDs.
deba@1018
  1091
      int maxRedId() const { return -1; }
deba@1018
  1092
deba@1018
  1093
      /// \brief An upper bound on the blue IDs.
deba@1018
  1094
      ///
deba@1018
  1095
      /// Returns an upper bound on the blue IDs.
deba@1018
  1096
      int maxBlueId() const { return -1; }
deba@1018
  1097
deba@1018
  1098
      /// \brief An upper bound on the edge IDs.
deba@1018
  1099
      ///
deba@1018
  1100
      /// Returns an upper bound on the edge IDs.
deba@1018
  1101
      int maxEdgeId() const { return -1; }
deba@1018
  1102
deba@1018
  1103
      /// \brief An upper bound on the arc IDs.
deba@1018
  1104
      ///
deba@1018
  1105
      /// Returns an upper bound on the arc IDs.
deba@1018
  1106
      int maxArcId() const { return -1; }
deba@1018
  1107
deba@1018
  1108
      /// \brief The direction of the arc.
deba@1018
  1109
      ///
deba@1018
  1110
      /// Returns \c true if the given arc goes from a red node to a blue node.
deba@1018
  1111
      bool direction(Arc) const { return true; }
deba@1018
  1112
deba@1018
  1113
      /// \brief Direct the edge.
deba@1018
  1114
      ///
deba@1018
  1115
      /// Direct the given edge. The returned arc
deba@1018
  1116
      /// represents the given edge and its direction comes
deba@1018
  1117
      /// from the bool parameter. If it is \c true, then the source of the node
deba@1018
  1118
      /// will be a red node.
deba@1018
  1119
      Arc direct(Edge, bool) const {
deba@1018
  1120
        return INVALID;
deba@1018
  1121
      }
deba@1018
  1122
deba@1018
  1123
      /// \brief Direct the edge.
deba@1018
  1124
      ///
deba@1018
  1125
      /// Direct the given edge. The returned arc represents the given
deba@1018
  1126
      /// edge and its source node is the given node.
deba@1018
  1127
      Arc direct(Edge, Node) const {
deba@1018
  1128
        return INVALID;
deba@1018
  1129
      }
deba@1018
  1130
deba@1018
  1131
      /// \brief The oppositely directed arc.
deba@1018
  1132
      ///
deba@1018
  1133
      /// Returns the oppositely directed arc representing the same edge.
deba@1018
  1134
      Arc oppositeArc(Arc) const { return INVALID; }
deba@1018
  1135
deba@1018
  1136
      /// \brief The opposite node on the edge.
deba@1018
  1137
      ///
deba@1018
  1138
      /// Returns the opposite node on the given edge.
deba@1018
  1139
      Node oppositeNode(Node, Edge) const { return INVALID; }
deba@1018
  1140
deba@1018
  1141
      void first(Node&) const {}
deba@1018
  1142
      void next(Node&) const {}
deba@1018
  1143
deba@1025
  1144
      void firstRed(RedNode&) const {}
deba@1025
  1145
      void nextRed(RedNode&) const {}
deba@1018
  1146
deba@1025
  1147
      void firstBlue(BlueNode&) const {}
deba@1025
  1148
      void nextBlue(BlueNode&) const {}
deba@1018
  1149
deba@1018
  1150
      void first(Edge&) const {}
deba@1018
  1151
      void next(Edge&) const {}
deba@1018
  1152
deba@1018
  1153
      void first(Arc&) const {}
deba@1018
  1154
      void next(Arc&) const {}
deba@1018
  1155
deba@1018
  1156
      void firstOut(Arc&, Node) const {}
deba@1018
  1157
      void nextOut(Arc&) const {}
deba@1018
  1158
deba@1018
  1159
      void firstIn(Arc&, Node) const {}
deba@1018
  1160
      void nextIn(Arc&) const {}
deba@1018
  1161
deba@1018
  1162
      void firstInc(Edge &, bool &, const Node &) const {}
deba@1018
  1163
      void nextInc(Edge &, bool &) const {}
deba@1018
  1164
deba@1018
  1165
      // The second parameter is dummy.
deba@1018
  1166
      Node fromId(int, Node) const { return INVALID; }
deba@1018
  1167
      // The second parameter is dummy.
deba@1018
  1168
      Edge fromId(int, Edge) const { return INVALID; }
deba@1018
  1169
      // The second parameter is dummy.
deba@1018
  1170
      Arc fromId(int, Arc) const { return INVALID; }
deba@1018
  1171
deba@1018
  1172
      // Dummy parameter.
deba@1018
  1173
      int maxId(Node) const { return -1; }
deba@1018
  1174
      // Dummy parameter.
deba@1018
  1175
      int maxId(RedNode) const { return -1; }
deba@1018
  1176
      // Dummy parameter.
deba@1018
  1177
      int maxId(BlueNode) const { return -1; }
deba@1018
  1178
      // Dummy parameter.
deba@1018
  1179
      int maxId(Edge) const { return -1; }
deba@1018
  1180
      // Dummy parameter.
deba@1018
  1181
      int maxId(Arc) const { return -1; }
deba@1018
  1182
deba@1018
  1183
      /// \brief The base node of the iterator.
deba@1018
  1184
      ///
deba@1018
  1185
      /// Returns the base node of the given incident edge iterator.
deba@1018
  1186
      Node baseNode(IncEdgeIt) const { return INVALID; }
deba@1018
  1187
deba@1018
  1188
      /// \brief The running node of the iterator.
deba@1018
  1189
      ///
deba@1018
  1190
      /// Returns the running node of the given incident edge iterator.
deba@1018
  1191
      Node runningNode(IncEdgeIt) const { return INVALID; }
deba@1018
  1192
deba@1018
  1193
      /// \brief The base node of the iterator.
deba@1018
  1194
      ///
deba@1018
  1195
      /// Returns the base node of the given outgoing arc iterator
deba@1018
  1196
      /// (i.e. the source node of the corresponding arc).
deba@1018
  1197
      Node baseNode(OutArcIt) const { return INVALID; }
deba@1018
  1198
deba@1018
  1199
      /// \brief The running node of the iterator.
deba@1018
  1200
      ///
deba@1018
  1201
      /// Returns the running node of the given outgoing arc iterator
deba@1018
  1202
      /// (i.e. the target node of the corresponding arc).
deba@1018
  1203
      Node runningNode(OutArcIt) const { return INVALID; }
deba@1018
  1204
deba@1018
  1205
      /// \brief The base node of the iterator.
deba@1018
  1206
      ///
kpeter@1049
  1207
      /// Returns the base node of the given incoming arc iterator
deba@1018
  1208
      /// (i.e. the target node of the corresponding arc).
deba@1018
  1209
      Node baseNode(InArcIt) const { return INVALID; }
deba@1018
  1210
deba@1018
  1211
      /// \brief The running node of the iterator.
deba@1018
  1212
      ///
kpeter@1049
  1213
      /// Returns the running node of the given incoming arc iterator
deba@1018
  1214
      /// (i.e. the source node of the corresponding arc).
deba@1018
  1215
      Node runningNode(InArcIt) const { return INVALID; }
deba@1018
  1216
deba@1018
  1217
      template <typename _BpGraph>
deba@1018
  1218
      struct Constraints {
deba@1018
  1219
        void constraints() {
deba@1018
  1220
          checkConcept<BaseBpGraphComponent, _BpGraph>();
deba@1018
  1221
          checkConcept<IterableBpGraphComponent<>, _BpGraph>();
deba@1018
  1222
          checkConcept<IDableBpGraphComponent<>, _BpGraph>();
deba@1018
  1223
          checkConcept<MappableBpGraphComponent<>, _BpGraph>();
deba@1018
  1224
        }
deba@1018
  1225
      };
deba@1018
  1226
deba@1018
  1227
    };
deba@1018
  1228
deba@1018
  1229
  }
deba@1018
  1230
deba@1018
  1231
}
deba@1018
  1232
deba@1018
  1233
#endif