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