1.1 --- a/CMakeLists.txt Thu Apr 02 22:34:03 2015 +0200
1.2 +++ b/CMakeLists.txt Sun Jan 05 22:24:56 2014 +0100
1.3 @@ -262,6 +262,14 @@
1.4
1.5 ENABLE_TESTING()
1.6
1.7 +
1.8 +INCLUDE(CheckCXXCompilerFlag)
1.9 +CHECK_CXX_COMPILER_FLAG("-std=c++11" CXX11FLAG)
1.10 +IF(CXX11FLAG)
1.11 + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
1.12 +ENDIF()
1.13 +
1.14 +
1.15 IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
1.16 ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
1.17 ELSE()
2.1 --- a/lemon/bellman_ford.h Thu Apr 02 22:34:03 2015 +0200
2.2 +++ b/lemon/bellman_ford.h Sun Jan 05 22:24:56 2014 +0100
2.3 @@ -29,6 +29,7 @@
2.4 #include <lemon/error.h>
2.5 #include <lemon/maps.h>
2.6 #include <lemon/path.h>
2.7 +#include <lemon/bits/stl_iterators.h>
2.8
2.9 #include <limits>
2.10
2.11 @@ -690,6 +691,21 @@
2.12 int _index;
2.13 };
2.14
2.15 + /// \brief Gets the collection of the active nodes.
2.16 + ///
2.17 + /// This function can be used for iterating on the active nodes of the
2.18 + /// Bellman-Ford algorithm after the last phase.
2.19 + /// These nodes should be checked in the next phase to
2.20 + /// find augmenting arcs outgoing from them.
2.21 + /// It returns a wrapped ActiveIt, which looks
2.22 + /// like an STL container (by having begin() and end())
2.23 + /// which you can use in range-based for loops, STL algorithms, etc.
2.24 + LemonRangeWrapper1<ActiveIt, BellmanFord>
2.25 + activeNodes(const BellmanFord& algorithm) const {
2.26 + return LemonRangeWrapper1<ActiveIt, BellmanFord>(algorithm);
2.27 + }
2.28 +
2.29 +
2.30 /// \name Query Functions
2.31 /// The result of the Bellman-Ford algorithm can be obtained using these
2.32 /// functions.\n
3.1 --- a/lemon/bits/graph_adaptor_extender.h Thu Apr 02 22:34:03 2015 +0200
3.2 +++ b/lemon/bits/graph_adaptor_extender.h Sun Jan 05 22:24:56 2014 +0100
3.3 @@ -85,6 +85,9 @@
3.4
3.5 };
3.6
3.7 + LemonRangeWrapper1<NodeIt, Adaptor> nodes() {
3.8 + return LemonRangeWrapper1<NodeIt, Adaptor>(*this);
3.9 + }
3.10
3.11 class ArcIt : public Arc {
3.12 const Adaptor* _adaptor;
3.13 @@ -108,6 +111,10 @@
3.14
3.15 };
3.16
3.17 + LemonRangeWrapper1<ArcIt, Adaptor> arcs() {
3.18 + return LemonRangeWrapper1<ArcIt, Adaptor>(*this);
3.19 + }
3.20 +
3.21
3.22 class OutArcIt : public Arc {
3.23 const Adaptor* _adaptor;
3.24 @@ -132,6 +139,10 @@
3.25
3.26 };
3.27
3.28 + LemonRangeWrapper2<OutArcIt, Adaptor, Node> outArcs(const Node& u) const {
3.29 + return LemonRangeWrapper2<OutArcIt, Adaptor, Node>(*this, u);
3.30 + }
3.31 +
3.32
3.33 class InArcIt : public Arc {
3.34 const Adaptor* _adaptor;
3.35 @@ -156,6 +167,10 @@
3.36
3.37 };
3.38
3.39 + LemonRangeWrapper2<InArcIt, Adaptor, Node> inArcs(const Node& u) const {
3.40 + return LemonRangeWrapper2<InArcIt, Adaptor, Node>(*this, u);
3.41 + }
3.42 +
3.43 Node baseNode(const OutArcIt &e) const {
3.44 return Parent::source(e);
3.45 }
3.46 @@ -254,6 +269,10 @@
3.47
3.48 };
3.49
3.50 + LemonRangeWrapper1<NodeIt, Adaptor> nodes() {
3.51 + return LemonRangeWrapper1<NodeIt, Adaptor>(*this);
3.52 + }
3.53 +
3.54
3.55 class ArcIt : public Arc {
3.56 const Adaptor* _adaptor;
3.57 @@ -277,6 +296,10 @@
3.58
3.59 };
3.60
3.61 + LemonRangeWrapper1<ArcIt, Adaptor> arcs() {
3.62 + return LemonRangeWrapper1<ArcIt, Adaptor>(*this);
3.63 + }
3.64 +
3.65
3.66 class OutArcIt : public Arc {
3.67 const Adaptor* _adaptor;
3.68 @@ -301,6 +324,10 @@
3.69
3.70 };
3.71
3.72 + LemonRangeWrapper2<OutArcIt, Adaptor, Node> outArcs(const Node& u) const {
3.73 + return LemonRangeWrapper2<OutArcIt, Adaptor, Node>(*this, u);
3.74 + }
3.75 +
3.76
3.77 class InArcIt : public Arc {
3.78 const Adaptor* _adaptor;
3.79 @@ -325,6 +352,10 @@
3.80
3.81 };
3.82
3.83 + LemonRangeWrapper2<InArcIt, Adaptor, Node> inArcs(const Node& u) const {
3.84 + return LemonRangeWrapper2<InArcIt, Adaptor, Node>(*this, u);
3.85 + }
3.86 +
3.87 class EdgeIt : public Parent::Edge {
3.88 const Adaptor* _adaptor;
3.89 public:
3.90 @@ -347,6 +378,11 @@
3.91
3.92 };
3.93
3.94 + LemonRangeWrapper1<EdgeIt, Adaptor> edges() {
3.95 + return LemonRangeWrapper1<EdgeIt, Adaptor>(*this);
3.96 + }
3.97 +
3.98 +
3.99 class IncEdgeIt : public Edge {
3.100 friend class GraphAdaptorExtender;
3.101 const Adaptor* _adaptor;
3.102 @@ -372,6 +408,11 @@
3.103 }
3.104 };
3.105
3.106 + LemonRangeWrapper2<IncEdgeIt, Adaptor, Node> incEdges(const Node& u) const {
3.107 + return LemonRangeWrapper2<IncEdgeIt, Adaptor, Node>(*this, u);
3.108 + }
3.109 +
3.110 +
3.111 Node baseNode(const OutArcIt &a) const {
3.112 return Parent::source(a);
3.113 }
4.1 --- a/lemon/bits/graph_extender.h Thu Apr 02 22:34:03 2015 +0200
4.2 +++ b/lemon/bits/graph_extender.h Sun Jan 05 22:24:56 2014 +0100
4.3 @@ -27,6 +27,8 @@
4.4 #include <lemon/concept_check.h>
4.5 #include <lemon/concepts/maps.h>
4.6
4.7 +#include <lemon/bits/stl_iterators.h>
4.8 +
4.9 //\ingroup graphbits
4.10 //\file
4.11 //\brief Extenders for the graph types
4.12 @@ -116,6 +118,10 @@
4.13
4.14 };
4.15
4.16 + LemonRangeWrapper1<NodeIt, Digraph> nodes() const {
4.17 + return LemonRangeWrapper1<NodeIt, Digraph>(*this);
4.18 + }
4.19 +
4.20
4.21 class ArcIt : public Arc {
4.22 const Digraph* _digraph;
4.23 @@ -139,6 +145,10 @@
4.24
4.25 };
4.26
4.27 + LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
4.28 + return LemonRangeWrapper1<ArcIt, Digraph>(*this);
4.29 + }
4.30 +
4.31
4.32 class OutArcIt : public Arc {
4.33 const Digraph* _digraph;
4.34 @@ -163,6 +173,10 @@
4.35
4.36 };
4.37
4.38 + LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
4.39 + return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
4.40 + }
4.41 +
4.42
4.43 class InArcIt : public Arc {
4.44 const Digraph* _digraph;
4.45 @@ -187,6 +201,10 @@
4.46
4.47 };
4.48
4.49 + LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
4.50 + return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
4.51 + }
4.52 +
4.53 // \brief Base node of the iterator
4.54 //
4.55 // Returns the base node (i.e. the source in this case) of the iterator
4.56 @@ -436,6 +454,10 @@
4.57
4.58 };
4.59
4.60 + LemonRangeWrapper1<NodeIt, Graph> nodes() const {
4.61 + return LemonRangeWrapper1<NodeIt, Graph>(*this);
4.62 + }
4.63 +
4.64
4.65 class ArcIt : public Arc {
4.66 const Graph* _graph;
4.67 @@ -459,6 +481,10 @@
4.68
4.69 };
4.70
4.71 + LemonRangeWrapper1<ArcIt, Graph> arcs() const {
4.72 + return LemonRangeWrapper1<ArcIt, Graph>(*this);
4.73 + }
4.74 +
4.75
4.76 class OutArcIt : public Arc {
4.77 const Graph* _graph;
4.78 @@ -483,6 +509,10 @@
4.79
4.80 };
4.81
4.82 + LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
4.83 + return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
4.84 + }
4.85 +
4.86
4.87 class InArcIt : public Arc {
4.88 const Graph* _graph;
4.89 @@ -507,6 +537,10 @@
4.90
4.91 };
4.92
4.93 + LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
4.94 + return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
4.95 + }
4.96 +
4.97
4.98 class EdgeIt : public Parent::Edge {
4.99 const Graph* _graph;
4.100 @@ -530,6 +564,11 @@
4.101
4.102 };
4.103
4.104 + LemonRangeWrapper1<EdgeIt, Graph> edges() const {
4.105 + return LemonRangeWrapper1<EdgeIt, Graph>(*this);
4.106 + }
4.107 +
4.108 +
4.109 class IncEdgeIt : public Parent::Edge {
4.110 friend class GraphExtender;
4.111 const Graph* _graph;
4.112 @@ -555,6 +594,11 @@
4.113 }
4.114 };
4.115
4.116 + LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
4.117 + return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
4.118 + }
4.119 +
4.120 +
4.121 // \brief Base node of the iterator
4.122 //
4.123 // Returns the base node (ie. the source in this case) of the iterator
4.124 @@ -903,6 +947,11 @@
4.125
4.126 };
4.127
4.128 + LemonRangeWrapper1<NodeIt, BpGraph> nodes() const {
4.129 + return LemonRangeWrapper1<NodeIt, BpGraph>(*this);
4.130 + }
4.131 +
4.132 +
4.133 class RedNodeIt : public RedNode {
4.134 const BpGraph* _graph;
4.135 public:
4.136 @@ -925,6 +974,11 @@
4.137
4.138 };
4.139
4.140 + LemonRangeWrapper1<RedNodeIt, BpGraph> redNodes() const {
4.141 + return LemonRangeWrapper1<RedNodeIt, BpGraph>(*this);
4.142 + }
4.143 +
4.144 +
4.145 class BlueNodeIt : public BlueNode {
4.146 const BpGraph* _graph;
4.147 public:
4.148 @@ -947,6 +1001,11 @@
4.149
4.150 };
4.151
4.152 + LemonRangeWrapper1<BlueNodeIt, BpGraph> blueNodes() const {
4.153 + return LemonRangeWrapper1<BlueNodeIt, BpGraph>(*this);
4.154 + }
4.155 +
4.156 +
4.157
4.158 class ArcIt : public Arc {
4.159 const BpGraph* _graph;
4.160 @@ -970,6 +1029,10 @@
4.161
4.162 };
4.163
4.164 + LemonRangeWrapper1<ArcIt, BpGraph> arcs() const {
4.165 + return LemonRangeWrapper1<ArcIt, BpGraph>(*this);
4.166 + }
4.167 +
4.168
4.169 class OutArcIt : public Arc {
4.170 const BpGraph* _graph;
4.171 @@ -994,6 +1057,10 @@
4.172
4.173 };
4.174
4.175 + LemonRangeWrapper2<OutArcIt, BpGraph, Node> outArcs(const Node& u) const {
4.176 + return LemonRangeWrapper2<OutArcIt, BpGraph, Node>(*this, u);
4.177 + }
4.178 +
4.179
4.180 class InArcIt : public Arc {
4.181 const BpGraph* _graph;
4.182 @@ -1018,6 +1085,10 @@
4.183
4.184 };
4.185
4.186 + LemonRangeWrapper2<InArcIt, BpGraph, Node> inArcs(const Node& u) const {
4.187 + return LemonRangeWrapper2<InArcIt, BpGraph, Node>(*this, u);
4.188 + }
4.189 +
4.190
4.191 class EdgeIt : public Parent::Edge {
4.192 const BpGraph* _graph;
4.193 @@ -1041,6 +1112,11 @@
4.194
4.195 };
4.196
4.197 + LemonRangeWrapper1<EdgeIt, BpGraph> edges() const {
4.198 + return LemonRangeWrapper1<EdgeIt, BpGraph>(*this);
4.199 + }
4.200 +
4.201 +
4.202 class IncEdgeIt : public Parent::Edge {
4.203 friend class BpGraphExtender;
4.204 const BpGraph* _graph;
4.205 @@ -1066,6 +1142,11 @@
4.206 }
4.207 };
4.208
4.209 + LemonRangeWrapper2<IncEdgeIt, BpGraph, Node> incEdges(const Node& u) const {
4.210 + return LemonRangeWrapper2<IncEdgeIt, BpGraph, Node>(*this, u);
4.211 + }
4.212 +
4.213 +
4.214 // \brief Base node of the iterator
4.215 //
4.216 // Returns the base node (ie. the source in this case) of the iterator
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/lemon/bits/stl_iterators.h Sun Jan 05 22:24:56 2014 +0100
5.3 @@ -0,0 +1,99 @@
5.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
5.5 + */
5.6 +
5.7 +#ifndef STL_ITERATORS_H_
5.8 +#define STL_ITERATORS_H_
5.9 +
5.10 +#include <lemon/core.h>
5.11 +
5.12 +namespace lemon {
5.13 +
5.14 + /// \brief Template to make STL iterators from Lemon iterators.
5.15 + ///
5.16 + /// This template makes an STL iterator from a Lemon iterator
5.17 + /// by adding the missing features.
5.18 + /// It inherits from \c std::iterator to make \c iterator_concept work
5.19 + /// (so that STL algorithms work).
5.20 + /// \c T should be the lemon iterator to be decorated.
5.21 + template<class T>
5.22 + struct LemonItWrapper
5.23 + : public T, public std::iterator<std::input_iterator_tag, T> {
5.24 +
5.25 + LemonItWrapper(const T &x) : T(x) {}
5.26 +
5.27 + //Lemon iterators don't have operator*, (because they rather
5.28 + //inherit from their "value_type"),
5.29 + //so we add one that just returns the object.
5.30 + const T& operator*() const {
5.31 + return static_cast<const T&>(*this);
5.32 + }
5.33 +
5.34 + //I can't think of any use case for this with Lemon iterators,
5.35 + //but maybe it should be included for completeness.
5.36 + const T* operator->() {
5.37 + return static_cast<const T*>(this);
5.38 + }
5.39 +
5.40 + //Lemon iterators don't have postincrement.
5.41 + void operator++(int) {
5.42 + T::operator++();
5.43 + }
5.44 +
5.45 + using T::operator++;
5.46 +
5.47 + };
5.48 +
5.49 +
5.50 + /// \brief A generic wrapper for Lemon iterators for range-based for loops.
5.51 + ///
5.52 + /// This template can be used to create a class
5.53 + /// that has begin() and end() from a Lemon iterator
5.54 + /// (with a 1-parameter constructor)
5.55 + /// to make range-based for loops and STL algorithms work.
5.56 + ///
5.57 + /// \c LIT is the Lemon iterator that will be wrapped
5.58 + /// \c P is the type of the parameter of the constructor of \c LIT.
5.59 + template<class LIT, class P>
5.60 + class LemonRangeWrapper1 {
5.61 + const P &_p;
5.62 + typedef LemonItWrapper<LIT> It;
5.63 + public:
5.64 + LemonRangeWrapper1(const P &p) : _p(p) {}
5.65 + It begin() const {
5.66 + return It(LIT(_p));
5.67 + }
5.68 + It end() const {
5.69 + return It(lemon::INVALID);
5.70 + }
5.71 + };
5.72 +
5.73 +
5.74 + /// \brief A generic wrapper for Lemon iterators for range-based for loops.
5.75 + ///
5.76 + /// This template can be used to create a class
5.77 + /// that has begin() and end() from a Lemon iterator
5.78 + /// (with a 2-parameter constructor)
5.79 + /// to make range-based for loops and STL algorithms work.
5.80 + ///
5.81 + /// \c LIT is the Lemon iterator that will be wrapped
5.82 + /// \c P1 and \c P2 are the types of the parameters
5.83 + /// of the constructor of \c LIT.
5.84 + template<class LIT, class P1, class P2>
5.85 + class LemonRangeWrapper2 {
5.86 + const P1 &_p1;
5.87 + const P2 &_p2;
5.88 + typedef LemonItWrapper<LIT> It;
5.89 + public:
5.90 + LemonRangeWrapper2(const P1 &p1, const P2 &p2) : _p1(p1), _p2(p2) {}
5.91 + It begin() const {
5.92 + return It(LIT(_p1, _p2));
5.93 + }
5.94 + It end() const {
5.95 + return It(lemon::INVALID);
5.96 + }
5.97 + };
5.98 +
5.99 +
5.100 +}
5.101 +
5.102 +#endif /* STL_ITERATORS_H_ */
6.1 --- a/lemon/cbc.cc Thu Apr 02 22:34:03 2015 +0200
6.2 +++ b/lemon/cbc.cc Sun Jan 05 22:24:56 2014 +0100
6.3 @@ -111,11 +111,11 @@
6.4 }
6.5
6.6 void CbcMip::_eraseColId(int i) {
6.7 - cols.eraseIndex(i);
6.8 + _cols.eraseIndex(i);
6.9 }
6.10
6.11 void CbcMip::_eraseRowId(int i) {
6.12 - rows.eraseIndex(i);
6.13 + _rows.eraseIndex(i);
6.14 }
6.15
6.16 void CbcMip::_getColName(int c, std::string& name) const {
7.1 --- a/lemon/clp.cc Thu Apr 02 22:34:03 2015 +0200
7.2 +++ b/lemon/clp.cc Sun Jan 05 22:24:56 2014 +0100
7.3 @@ -29,8 +29,8 @@
7.4
7.5 ClpLp::ClpLp(const ClpLp& other) {
7.6 _prob = new ClpSimplex(*other._prob);
7.7 - rows = other.rows;
7.8 - cols = other.cols;
7.9 + _rows = other._rows;
7.10 + _cols = other._cols;
7.11 _init_temporals();
7.12 messageLevel(MESSAGE_NOTHING);
7.13 }
7.14 @@ -103,13 +103,13 @@
7.15 }
7.16
7.17 void ClpLp::_eraseColId(int i) {
7.18 - cols.eraseIndex(i);
7.19 - cols.shiftIndices(i);
7.20 + _cols.eraseIndex(i);
7.21 + _cols.shiftIndices(i);
7.22 }
7.23
7.24 void ClpLp::_eraseRowId(int i) {
7.25 - rows.eraseIndex(i);
7.26 - rows.shiftIndices(i);
7.27 + _rows.eraseIndex(i);
7.28 + _rows.shiftIndices(i);
7.29 }
7.30
7.31 void ClpLp::_getColName(int c, std::string& name) const {
8.1 --- a/lemon/clp.h Thu Apr 02 22:34:03 2015 +0200
8.2 +++ b/lemon/clp.h Sun Jan 05 22:24:56 2014 +0100
8.3 @@ -151,10 +151,10 @@
8.4 SolveExitStatus solveBarrier();
8.5
8.6 ///Returns the constraint identifier understood by CLP.
8.7 - int clpRow(Row r) const { return rows(id(r)); }
8.8 + int clpRow(Row r) const { return _rows(id(r)); }
8.9
8.10 ///Returns the variable identifier understood by CLP.
8.11 - int clpCol(Col c) const { return cols(id(c)); }
8.12 + int clpCol(Col c) const { return _cols(id(c)); }
8.13
8.14 };
8.15
9.1 --- a/lemon/concepts/bpgraph.h Thu Apr 02 22:34:03 2015 +0200
9.2 +++ b/lemon/concepts/bpgraph.h Sun Jan 05 22:24:56 2014 +0100
9.3 @@ -27,6 +27,7 @@
9.4 #include <lemon/concepts/maps.h>
9.5 #include <lemon/concept_check.h>
9.6 #include <lemon/core.h>
9.7 +#include <lemon/bits/stl_iterators.h>
9.8
9.9 namespace lemon {
9.10 namespace concepts {
9.11 @@ -221,6 +222,22 @@
9.12 RedNodeIt& operator++() { return *this; }
9.13 };
9.14
9.15 + /// \brief Gets the collection of the red nodes of the graph.
9.16 + ///
9.17 + /// This function can be used for iterating on
9.18 + /// the red nodes of the graph. It returns a wrapped RedNodeIt,
9.19 + /// which looks like an STL container (by having begin() and end())
9.20 + /// which you can use in range-based for loops, stl algorithms, etc.
9.21 + /// For example if g is a BpGraph, you can write:
9.22 + ///\code
9.23 + /// for(auto v: g.redNodes())
9.24 + /// doSomething(v);
9.25 + ///\endcode
9.26 + LemonRangeWrapper1<RedNodeIt, BpGraph> redNodes() const {
9.27 + return LemonRangeWrapper1<RedNodeIt, BpGraph>(*this);
9.28 + }
9.29 +
9.30 +
9.31 /// Iterator class for the blue nodes.
9.32
9.33 /// This iterator goes through each blue node of the graph.
9.34 @@ -264,6 +281,22 @@
9.35 BlueNodeIt& operator++() { return *this; }
9.36 };
9.37
9.38 + /// \brief Gets the collection of the blue nodes of the graph.
9.39 + ///
9.40 + /// This function can be used for iterating on
9.41 + /// the blue nodes of the graph. It returns a wrapped BlueNodeIt,
9.42 + /// which looks like an STL container (by having begin() and end())
9.43 + /// which you can use in range-based for loops, stl algorithms, etc.
9.44 + /// For example if g is a BpGraph, you can write:
9.45 + ///\code
9.46 + /// for(auto v: g.blueNodes())
9.47 + /// doSomething(v);
9.48 + ///\endcode
9.49 + LemonRangeWrapper1<BlueNodeIt, BpGraph> blueNodes() const {
9.50 + return LemonRangeWrapper1<BlueNodeIt, BpGraph>(*this);
9.51 + }
9.52 +
9.53 +
9.54 /// Iterator class for the nodes.
9.55
9.56 /// This iterator goes through each node of the graph.
9.57 @@ -307,6 +340,22 @@
9.58 NodeIt& operator++() { return *this; }
9.59 };
9.60
9.61 + /// \brief Gets the collection of the nodes of the graph.
9.62 + ///
9.63 + /// This function can be used for iterating on
9.64 + /// the nodes of the graph. It returns a wrapped NodeIt,
9.65 + /// which looks like an STL container (by having begin() and end())
9.66 + /// which you can use in range-based for loops, stl algorithms, etc.
9.67 + /// For example if g is a BpGraph, you can write:
9.68 + ///\code
9.69 + /// for(auto v: g.nodes())
9.70 + /// doSomething(v);
9.71 + ///\endcode
9.72 + LemonRangeWrapper1<NodeIt, BpGraph> nodes() const {
9.73 + return LemonRangeWrapper1<NodeIt, BpGraph>(*this);
9.74 + }
9.75 +
9.76 +
9.77
9.78 /// The edge type of the graph
9.79
9.80 @@ -395,6 +444,23 @@
9.81 EdgeIt& operator++() { return *this; }
9.82 };
9.83
9.84 + /// \brief Gets the collection of the edges of the graph.
9.85 + ///
9.86 + /// This function can be used for iterating on the
9.87 + /// edges of the graph. It returns a wrapped
9.88 + /// EdgeIt, which looks like an STL container
9.89 + /// (by having begin() and end()) which you can use in range-based
9.90 + /// for loops, stl algorithms, etc.
9.91 + /// For example if g is a BpGraph, you can write:
9.92 + ///\code
9.93 + /// for(auto e: g.edges())
9.94 + /// doSomething(e);
9.95 + ///\endcode
9.96 + LemonRangeWrapper1<EdgeIt, BpGraph> edges() const {
9.97 + return LemonRangeWrapper1<EdgeIt, BpGraph>(*this);
9.98 + }
9.99 +
9.100 +
9.101 /// Iterator class for the incident edges of a node.
9.102
9.103 /// This iterator goes trough the incident undirected edges
9.104 @@ -443,6 +509,25 @@
9.105 IncEdgeIt& operator++() { return *this; }
9.106 };
9.107
9.108 + /// \brief Gets the collection of the incident edges
9.109 + /// of a certain node of the graph.
9.110 + ///
9.111 + /// This function can be used for iterating on the
9.112 + /// incident undirected edges of a certain node of the graph.
9.113 + /// It returns a wrapped
9.114 + /// IncEdgeIt, which looks like an STL container
9.115 + /// (by having begin() and end()) which you can use in range-based
9.116 + /// for loops, stl algorithms, etc.
9.117 + /// For example if g is a BpGraph and u is a Node, you can write:
9.118 + ///\code
9.119 + /// for(auto e: g.incEdges(u))
9.120 + /// doSomething(e);
9.121 + ///\endcode
9.122 + LemonRangeWrapper2<IncEdgeIt, BpGraph, Node> incEdges(const Node& u) const {
9.123 + return LemonRangeWrapper2<IncEdgeIt, BpGraph, Node>(*this, u);
9.124 + }
9.125 +
9.126 +
9.127 /// The arc type of the graph
9.128
9.129 /// This class identifies a directed arc of the graph. It also serves
9.130 @@ -539,6 +624,23 @@
9.131 ArcIt& operator++() { return *this; }
9.132 };
9.133
9.134 + /// \brief Gets the collection of the directed arcs of the graph.
9.135 + ///
9.136 + /// This function can be used for iterating on the
9.137 + /// arcs of the graph. It returns a wrapped
9.138 + /// ArcIt, which looks like an STL container
9.139 + /// (by having begin() and end()) which you can use in range-based
9.140 + /// for loops, stl algorithms, etc.
9.141 + /// For example if g is a BpGraph you can write:
9.142 + ///\code
9.143 + /// for(auto a: g.arcs())
9.144 + /// doSomething(a);
9.145 + ///\endcode
9.146 + LemonRangeWrapper1<ArcIt, BpGraph> arcs() const {
9.147 + return LemonRangeWrapper1<ArcIt, BpGraph>(*this);
9.148 + }
9.149 +
9.150 +
9.151 /// Iterator class for the outgoing arcs of a node.
9.152
9.153 /// This iterator goes trough the \e outgoing directed arcs of a
9.154 @@ -587,6 +689,24 @@
9.155 OutArcIt& operator++() { return *this; }
9.156 };
9.157
9.158 + /// \brief Gets the collection of the outgoing directed arcs of a
9.159 + /// certain node of the graph.
9.160 + ///
9.161 + /// This function can be used for iterating on the
9.162 + /// outgoing arcs of a certain node of the graph. It returns a wrapped
9.163 + /// OutArcIt, which looks like an STL container
9.164 + /// (by having begin() and end()) which you can use in range-based
9.165 + /// for loops, stl algorithms, etc.
9.166 + /// For example if g is a BpGraph and u is a Node, you can write:
9.167 + ///\code
9.168 + /// for(auto a: g.outArcs(u))
9.169 + /// doSomething(a);
9.170 + ///\endcode
9.171 + LemonRangeWrapper2<OutArcIt, BpGraph, Node> outArcs(const Node& u) const {
9.172 + return LemonRangeWrapper2<OutArcIt, BpGraph, Node>(*this, u);
9.173 + }
9.174 +
9.175 +
9.176 /// Iterator class for the incoming arcs of a node.
9.177
9.178 /// This iterator goes trough the \e incoming directed arcs of a
9.179 @@ -635,6 +755,24 @@
9.180 InArcIt& operator++() { return *this; }
9.181 };
9.182
9.183 + /// \brief Gets the collection of the incoming directed arcs of a
9.184 + /// certain node of the graph.
9.185 + ///
9.186 + /// This function can be used for iterating on the
9.187 + /// incoming arcs of a certain node of the graph. It returns a wrapped
9.188 + /// InArcIt, which looks like an STL container
9.189 + /// (by having begin() and end()) which you can use in range-based
9.190 + /// for loops, stl algorithms, etc.
9.191 + /// For example if g is a BpGraph and u is a Node, you can write:
9.192 + ///\code
9.193 + /// for(auto a: g.inArcs(u))
9.194 + /// doSomething(a);
9.195 + ///\endcode
9.196 + LemonRangeWrapper2<InArcIt, BpGraph, Node> inArcs(const Node& u) const {
9.197 + return LemonRangeWrapper2<InArcIt, BpGraph, Node>(*this, u);
9.198 + }
9.199 +
9.200 +
9.201 /// \brief Standard graph map type for the nodes.
9.202 ///
9.203 /// Standard graph map type for the nodes.
10.1 --- a/lemon/concepts/digraph.h Thu Apr 02 22:34:03 2015 +0200
10.2 +++ b/lemon/concepts/digraph.h Sun Jan 05 22:24:56 2014 +0100
10.3 @@ -27,6 +27,7 @@
10.4 #include <lemon/concepts/maps.h>
10.5 #include <lemon/concept_check.h>
10.6 #include <lemon/concepts/graph_components.h>
10.7 +#include <lemon/bits/stl_iterators.h>
10.8
10.9 namespace lemon {
10.10 namespace concepts {
10.11 @@ -147,6 +148,25 @@
10.12 NodeIt& operator++() { return *this; }
10.13 };
10.14
10.15 + /// \brief Gets the collection of the nodes of the digraph.
10.16 + ///
10.17 + /// This function can be used for iterating on
10.18 + /// the nodes of the digraph. It returns a wrapped NodeIt, which looks
10.19 + /// like an STL container (by having begin() and end())
10.20 + /// which you can use in range-based for loops, STL algorithms, etc.
10.21 + /// For example you can write:
10.22 + ///\code
10.23 + /// ListDigraph g;
10.24 + /// for(auto v: g.nodes())
10.25 + /// doSomething(v);
10.26 + ///
10.27 + /// //Using an STL algorithm:
10.28 + /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
10.29 + ///\endcode
10.30 + LemonRangeWrapper1<NodeIt, Digraph> nodes() const {
10.31 + return LemonRangeWrapper1<NodeIt, Digraph>(*this);
10.32 + }
10.33 +
10.34
10.35 /// The arc type of the digraph
10.36
10.37 @@ -237,6 +257,27 @@
10.38 OutArcIt& operator++() { return *this; }
10.39 };
10.40
10.41 + /// \brief Gets the collection of the outgoing arcs of a certain node
10.42 + /// of the digraph.
10.43 + ///
10.44 + /// This function can be used for iterating on the
10.45 + /// outgoing arcs of a certain node of the digraph. It returns a wrapped
10.46 + /// OutArcIt, which looks like an STL container
10.47 + /// (by having begin() and end()) which you can use in range-based
10.48 + /// for loops, STL algorithms, etc.
10.49 + /// For example if g is a Digraph and u is a node, you can write:
10.50 + ///\code
10.51 + /// for(auto a: g.outArcs(u))
10.52 + /// doSomething(a);
10.53 + ///
10.54 + /// //Using an STL algorithm:
10.55 + /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
10.56 + ///\endcode
10.57 + LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
10.58 + return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
10.59 + }
10.60 +
10.61 +
10.62 /// Iterator class for the incoming arcs of a node.
10.63
10.64 /// This iterator goes trough the \e incoming arcs of a certain node
10.65 @@ -282,6 +323,27 @@
10.66 InArcIt& operator++() { return *this; }
10.67 };
10.68
10.69 + /// \brief Gets the collection of the incoming arcs of a certain node
10.70 + /// of the digraph.
10.71 + ///
10.72 + /// This function can be used for iterating on the
10.73 + /// incoming arcs of a certain node of the digraph. It returns a wrapped
10.74 + /// InArcIt, which looks like an STL container
10.75 + /// (by having begin() and end()) which you can use in range-based
10.76 + /// for loops, STL algorithms, etc.
10.77 + /// For example if g is a Digraph and u is a node, you can write:
10.78 + ///\code
10.79 + /// for(auto a: g.inArcs(u))
10.80 + /// doSomething(a);
10.81 + ///
10.82 + /// //Using an STL algorithm:
10.83 + /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
10.84 + ///\endcode
10.85 + LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
10.86 + return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
10.87 + }
10.88 +
10.89 +
10.90 /// Iterator class for the arcs.
10.91
10.92 /// This iterator goes through each arc of the digraph.
10.93 @@ -327,6 +389,27 @@
10.94 ArcIt& operator++() { return *this; }
10.95 };
10.96
10.97 + /// \brief Gets the collection of the arcs of the digraph.
10.98 + ///
10.99 + /// This function can be used for iterating on the
10.100 + /// arcs of the digraph. It returns a wrapped
10.101 + /// ArcIt, which looks like an STL container
10.102 + /// (by having begin() and end()) which you can use in range-based
10.103 + /// for loops, STL algorithms, etc.
10.104 + /// For example you can write:
10.105 + ///\code
10.106 + /// ListDigraph g;
10.107 + /// for(auto a: g.arcs())
10.108 + /// doSomething(a);
10.109 + ///
10.110 + /// //Using an STL algorithm:
10.111 + /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
10.112 + ///\endcode
10.113 + LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
10.114 + return LemonRangeWrapper1<ArcIt, Digraph>(*this);
10.115 + }
10.116 +
10.117 +
10.118 /// \brief The source node of the arc.
10.119 ///
10.120 /// Returns the source node of the given arc.
11.1 --- a/lemon/concepts/graph.h Thu Apr 02 22:34:03 2015 +0200
11.2 +++ b/lemon/concepts/graph.h Sun Jan 05 22:24:56 2014 +0100
11.3 @@ -27,6 +27,7 @@
11.4 #include <lemon/concepts/maps.h>
11.5 #include <lemon/concept_check.h>
11.6 #include <lemon/core.h>
11.7 +#include <lemon/bits/stl_iterators.h>
11.8
11.9 namespace lemon {
11.10 namespace concepts {
11.11 @@ -180,6 +181,25 @@
11.12 NodeIt& operator++() { return *this; }
11.13 };
11.14
11.15 + /// \brief Gets the collection of the nodes of the graph.
11.16 + ///
11.17 + /// This function can be used for iterating on
11.18 + /// the nodes of the graph. It returns a wrapped NodeIt, which looks
11.19 + /// like an STL container (by having begin() and end())
11.20 + /// which you can use in range-based for loops, STL algorithms, etc.
11.21 + /// For example you can write:
11.22 + ///\code
11.23 + /// ListGraph g;
11.24 + /// for(auto v: g.nodes())
11.25 + /// doSomething(v);
11.26 + ///
11.27 + /// //Using an STL algorithm:
11.28 + /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
11.29 + ///\endcode
11.30 + LemonRangeWrapper1<NodeIt, Graph> nodes() const {
11.31 + return LemonRangeWrapper1<NodeIt, Graph>(*this);
11.32 + }
11.33 +
11.34
11.35 /// The edge type of the graph
11.36
11.37 @@ -268,6 +288,27 @@
11.38 EdgeIt& operator++() { return *this; }
11.39 };
11.40
11.41 + /// \brief Gets the collection of the edges of the graph.
11.42 + ///
11.43 + /// This function can be used for iterating on the
11.44 + /// edges of the graph. It returns a wrapped
11.45 + /// EdgeIt, which looks like an STL container
11.46 + /// (by having begin() and end()) which you can use in range-based
11.47 + /// for loops, STL algorithms, etc.
11.48 + /// For example you can write:
11.49 + ///\code
11.50 + /// ListGraph g;
11.51 + /// for(auto e: g.edges())
11.52 + /// doSomething(e);
11.53 + ///
11.54 + /// //Using an STL algorithm:
11.55 + /// copy(g.edges().begin(), g.edges().end(), vect.begin());
11.56 + ///\endcode
11.57 + LemonRangeWrapper1<EdgeIt, Graph> edges() const {
11.58 + return LemonRangeWrapper1<EdgeIt, Graph>(*this);
11.59 + }
11.60 +
11.61 +
11.62 /// Iterator class for the incident edges of a node.
11.63
11.64 /// This iterator goes trough the incident undirected edges
11.65 @@ -316,6 +357,28 @@
11.66 IncEdgeIt& operator++() { return *this; }
11.67 };
11.68
11.69 + /// \brief Gets the collection of the incident undirected edges
11.70 + /// of a certain node of the graph.
11.71 + ///
11.72 + /// This function can be used for iterating on the
11.73 + /// incident undirected edges of a certain node of the graph.
11.74 + /// It returns a wrapped
11.75 + /// IncEdgeIt, which looks like an STL container
11.76 + /// (by having begin() and end()) which you can use in range-based
11.77 + /// for loops, STL algorithms, etc.
11.78 + /// For example if g is a Graph and u is a Node, you can write:
11.79 + ///\code
11.80 + /// for(auto e: g.incEdges(u))
11.81 + /// doSomething(e);
11.82 + ///
11.83 + /// //Using an STL algorithm:
11.84 + /// copy(g.incEdges(u).begin(), g.incEdges(u).end(), vect.begin());
11.85 + ///\endcode
11.86 + LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
11.87 + return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
11.88 + }
11.89 +
11.90 +
11.91 /// The arc type of the graph
11.92
11.93 /// This class identifies a directed arc of the graph. It also serves
11.94 @@ -411,6 +474,27 @@
11.95 ArcIt& operator++() { return *this; }
11.96 };
11.97
11.98 + /// \brief Gets the collection of the directed arcs of the graph.
11.99 + ///
11.100 + /// This function can be used for iterating on the
11.101 + /// arcs of the graph. It returns a wrapped
11.102 + /// ArcIt, which looks like an STL container
11.103 + /// (by having begin() and end()) which you can use in range-based
11.104 + /// for loops, STL algorithms, etc.
11.105 + /// For example you can write:
11.106 + ///\code
11.107 + /// ListGraph g;
11.108 + /// for(auto a: g.arcs())
11.109 + /// doSomething(a);
11.110 + ///
11.111 + /// //Using an STL algorithm:
11.112 + /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
11.113 + ///\endcode
11.114 + LemonRangeWrapper1<ArcIt, Graph> arcs() const {
11.115 + return LemonRangeWrapper1<ArcIt, Graph>(*this);
11.116 + }
11.117 +
11.118 +
11.119 /// Iterator class for the outgoing arcs of a node.
11.120
11.121 /// This iterator goes trough the \e outgoing directed arcs of a
11.122 @@ -459,6 +543,27 @@
11.123 OutArcIt& operator++() { return *this; }
11.124 };
11.125
11.126 + /// \brief Gets the collection of the outgoing directed arcs of a
11.127 + /// certain node of the graph.
11.128 + ///
11.129 + /// This function can be used for iterating on the
11.130 + /// outgoing arcs of a certain node of the graph. It returns a wrapped
11.131 + /// OutArcIt, which looks like an STL container
11.132 + /// (by having begin() and end()) which you can use in range-based
11.133 + /// for loops, STL algorithms, etc.
11.134 + /// For example if g is a Graph and u is a Node, you can write:
11.135 + ///\code
11.136 + /// for(auto a: g.outArcs(u))
11.137 + /// doSomething(a);
11.138 + ///
11.139 + /// //Using an STL algorithm:
11.140 + /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
11.141 + ///\endcode
11.142 + LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
11.143 + return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
11.144 + }
11.145 +
11.146 +
11.147 /// Iterator class for the incoming arcs of a node.
11.148
11.149 /// This iterator goes trough the \e incoming directed arcs of a
11.150 @@ -507,6 +612,26 @@
11.151 InArcIt& operator++() { return *this; }
11.152 };
11.153
11.154 + /// \brief Gets the collection of the incoming directed arcs of
11.155 + /// a certain node of the graph.
11.156 + ///
11.157 + /// This function can be used for iterating on the
11.158 + /// incoming directed arcs of a certain node of the graph. It returns
11.159 + /// a wrapped InArcIt, which looks like an STL container
11.160 + /// (by having begin() and end()) which you can use in range-based
11.161 + /// for loops, STL algorithms, etc.
11.162 + /// For example if g is a Graph and u is a Node, you can write:
11.163 + ///\code
11.164 + /// for(auto a: g.inArcs(u))
11.165 + /// doSomething(a);
11.166 + ///
11.167 + /// //Using an STL algorithm:
11.168 + /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
11.169 + ///\endcode
11.170 + LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
11.171 + return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
11.172 + }
11.173 +
11.174 /// \brief Standard graph map type for the nodes.
11.175 ///
11.176 /// Standard graph map type for the nodes.
12.1 --- a/lemon/concepts/path.h Thu Apr 02 22:34:03 2015 +0200
12.2 +++ b/lemon/concepts/path.h Sun Jan 05 22:24:56 2014 +0100
12.3 @@ -26,6 +26,7 @@
12.4
12.5 #include <lemon/core.h>
12.6 #include <lemon/concept_check.h>
12.7 +#include <lemon/bits/stl_iterators.h>
12.8
12.9 namespace lemon {
12.10 namespace concepts {
12.11 @@ -115,6 +116,23 @@
12.12
12.13 };
12.14
12.15 + /// \brief Gets the collection of the arcs of the path.
12.16 + ///
12.17 + /// This function can be used for iterating on the
12.18 + /// arcs of the path. It returns a wrapped
12.19 + /// ArcIt, which looks like an STL container
12.20 + /// (by having begin() and end()) which you can use in range-based
12.21 + /// for loops, STL algorithms, etc.
12.22 + /// For example you can write:
12.23 + ///\code
12.24 + /// for(auto a: p.arcs())
12.25 + /// doSomething(a);
12.26 + ///\endcode
12.27 + LemonRangeWrapper1<ArcIt, Path> arcs() const {
12.28 + return LemonRangeWrapper1<ArcIt, Path>(*this);
12.29 + }
12.30 +
12.31 +
12.32 template <typename _Path>
12.33 struct Constraints {
12.34 void constraints() {
12.35 @@ -264,6 +282,23 @@
12.36
12.37 };
12.38
12.39 + /// \brief Gets the collection of the arcs of the path.
12.40 + ///
12.41 + /// This function can be used for iterating on the
12.42 + /// arcs of the path. It returns a wrapped
12.43 + /// ArcIt, which looks like an STL container
12.44 + /// (by having begin() and end()) which you can use in range-based
12.45 + /// for loops, STL algorithms, etc.
12.46 + /// For example you can write:
12.47 + ///\code
12.48 + /// for(auto a: p.arcs())
12.49 + /// doSomething(a);
12.50 + ///\endcode
12.51 + LemonRangeWrapper1<ArcIt, PathDumper> arcs() const {
12.52 + return LemonRangeWrapper1<ArcIt, PathDumper>(*this);
12.53 + }
12.54 +
12.55 +
12.56 /// \brief LEMON style iterator for enumerating the arcs of a path
12.57 /// in reverse direction.
12.58 ///
12.59 @@ -293,6 +328,24 @@
12.60
12.61 };
12.62
12.63 + /// \brief Gets the collection of the arcs of the path
12.64 + /// in reverse direction.
12.65 + ///
12.66 + /// This function can be used for iterating on the
12.67 + /// arcs of the path in reverse direction. It returns a wrapped
12.68 + /// RevArcIt, which looks like an STL container
12.69 + /// (by having begin() and end()) which you can use in range-based
12.70 + /// for loops, STL algorithms, etc.
12.71 + /// For example you can write:
12.72 + ///\code
12.73 + /// for(auto a: p.revArcs())
12.74 + /// doSomething(a);
12.75 + ///\endcode
12.76 + LemonRangeWrapper1<RevArcIt, PathDumper> revArcs() const {
12.77 + return LemonRangeWrapper1<RevArcIt, PathDumper>(*this);
12.78 + }
12.79 +
12.80 +
12.81 template <typename _Path>
12.82 struct Constraints {
12.83 void constraints() {
13.1 --- a/lemon/cplex.cc Thu Apr 02 22:34:03 2015 +0200
13.2 +++ b/lemon/cplex.cc Sun Jan 05 22:24:56 2014 +0100
13.3 @@ -87,8 +87,8 @@
13.4 : LpBase() {
13.5 int status;
13.6 _prob = CPXcloneprob(cplexEnv(), cplex._prob, &status);
13.7 - rows = cplex.rows;
13.8 - cols = cplex.cols;
13.9 + _rows = cplex._rows;
13.10 + _cols = cplex._cols;
13.11 messageLevel(MESSAGE_NOTHING);
13.12 }
13.13
13.14 @@ -158,12 +158,12 @@
13.15 }
13.16
13.17 void CplexBase::_eraseColId(int i) {
13.18 - cols.eraseIndex(i);
13.19 - cols.shiftIndices(i);
13.20 + _cols.eraseIndex(i);
13.21 + _cols.shiftIndices(i);
13.22 }
13.23 void CplexBase::_eraseRowId(int i) {
13.24 - rows.eraseIndex(i);
13.25 - rows.shiftIndices(i);
13.26 + _rows.eraseIndex(i);
13.27 + _rows.shiftIndices(i);
13.28 }
13.29
13.30 void CplexBase::_getColName(int col, std::string &name) const {
14.1 --- a/lemon/glpk.cc Thu Apr 02 22:34:03 2015 +0200
14.2 +++ b/lemon/glpk.cc Sun Jan 05 22:24:56 2014 +0100
14.3 @@ -38,8 +38,8 @@
14.4 lp = glp_create_prob();
14.5 glp_copy_prob(lp, other.lp, GLP_ON);
14.6 glp_create_index(lp);
14.7 - rows = other.rows;
14.8 - cols = other.cols;
14.9 + _rows = other._rows;
14.10 + _cols = other._cols;
14.11 messageLevel(MESSAGE_NOTHING);
14.12 }
14.13
14.14 @@ -108,13 +108,13 @@
14.15 }
14.16
14.17 void GlpkBase::_eraseColId(int i) {
14.18 - cols.eraseIndex(i);
14.19 - cols.shiftIndices(i);
14.20 + _cols.eraseIndex(i);
14.21 + _cols.shiftIndices(i);
14.22 }
14.23
14.24 void GlpkBase::_eraseRowId(int i) {
14.25 - rows.eraseIndex(i);
14.26 - rows.shiftIndices(i);
14.27 + _rows.eraseIndex(i);
14.28 + _rows.shiftIndices(i);
14.29 }
14.30
14.31 void GlpkBase::_getColName(int c, std::string& name) const {
15.1 --- a/lemon/glpk.h Thu Apr 02 22:34:03 2015 +0200
15.2 +++ b/lemon/glpk.h Sun Jan 05 22:24:56 2014 +0100
15.3 @@ -141,10 +141,10 @@
15.4 _solver_bits::VoidPtr lpx() const {return lp;}
15.5
15.6 ///Returns the constraint identifier understood by GLPK.
15.7 - int lpxRow(Row r) const { return rows(id(r)); }
15.8 + int lpxRow(Row r) const { return _rows(id(r)); }
15.9
15.10 ///Returns the variable identifier understood by GLPK.
15.11 - int lpxCol(Col c) const { return cols(id(c)); }
15.12 + int lpxCol(Col c) const { return _cols(id(c)); }
15.13
15.14 #ifdef DOXYGEN
15.15 /// Write the problem or the solution to a file in the given format
16.1 --- a/lemon/list_graph.h Thu Apr 02 22:34:03 2015 +0200
16.2 +++ b/lemon/list_graph.h Sun Jan 05 22:24:56 2014 +0100
16.3 @@ -48,13 +48,13 @@
16.4 int next_in, next_out;
16.5 };
16.6
16.7 - std::vector<NodeT> nodes;
16.8 + std::vector<NodeT> _nodes;
16.9
16.10 int first_node;
16.11
16.12 int first_free_node;
16.13
16.14 - std::vector<ArcT> arcs;
16.15 + std::vector<ArcT> _arcs;
16.16
16.17 int first_free_arc;
16.18
16.19 @@ -97,15 +97,15 @@
16.20
16.21
16.22 ListDigraphBase()
16.23 - : nodes(), first_node(-1),
16.24 - first_free_node(-1), arcs(), first_free_arc(-1) {}
16.25 -
16.26 -
16.27 - int maxNodeId() const { return nodes.size()-1; }
16.28 - int maxArcId() const { return arcs.size()-1; }
16.29 -
16.30 - Node source(Arc e) const { return Node(arcs[e.id].source); }
16.31 - Node target(Arc e) const { return Node(arcs[e.id].target); }
16.32 + : _nodes(), first_node(-1),
16.33 + first_free_node(-1), _arcs(), first_free_arc(-1) {}
16.34 +
16.35 +
16.36 + int maxNodeId() const { return _nodes.size()-1; }
16.37 + int maxArcId() const { return _arcs.size()-1; }
16.38 +
16.39 + Node source(Arc e) const { return Node(_arcs[e.id].source); }
16.40 + Node target(Arc e) const { return Node(_arcs[e.id].target); }
16.41
16.42
16.43 void first(Node& node) const {
16.44 @@ -113,42 +113,42 @@
16.45 }
16.46
16.47 void next(Node& node) const {
16.48 - node.id = nodes[node.id].next;
16.49 + node.id = _nodes[node.id].next;
16.50 }
16.51
16.52
16.53 void first(Arc& arc) const {
16.54 int n;
16.55 for(n = first_node;
16.56 - n != -1 && nodes[n].first_out == -1;
16.57 - n = nodes[n].next) {}
16.58 - arc.id = (n == -1) ? -1 : nodes[n].first_out;
16.59 + n != -1 && _nodes[n].first_out == -1;
16.60 + n = _nodes[n].next) {}
16.61 + arc.id = (n == -1) ? -1 : _nodes[n].first_out;
16.62 }
16.63
16.64 void next(Arc& arc) const {
16.65 - if (arcs[arc.id].next_out != -1) {
16.66 - arc.id = arcs[arc.id].next_out;
16.67 + if (_arcs[arc.id].next_out != -1) {
16.68 + arc.id = _arcs[arc.id].next_out;
16.69 } else {
16.70 int n;
16.71 - for(n = nodes[arcs[arc.id].source].next;
16.72 - n != -1 && nodes[n].first_out == -1;
16.73 - n = nodes[n].next) {}
16.74 - arc.id = (n == -1) ? -1 : nodes[n].first_out;
16.75 + for(n = _nodes[_arcs[arc.id].source].next;
16.76 + n != -1 && _nodes[n].first_out == -1;
16.77 + n = _nodes[n].next) {}
16.78 + arc.id = (n == -1) ? -1 : _nodes[n].first_out;
16.79 }
16.80 }
16.81
16.82 void firstOut(Arc &e, const Node& v) const {
16.83 - e.id = nodes[v.id].first_out;
16.84 + e.id = _nodes[v.id].first_out;
16.85 }
16.86 void nextOut(Arc &e) const {
16.87 - e.id=arcs[e.id].next_out;
16.88 + e.id=_arcs[e.id].next_out;
16.89 }
16.90
16.91 void firstIn(Arc &e, const Node& v) const {
16.92 - e.id = nodes[v.id].first_in;
16.93 + e.id = _nodes[v.id].first_in;
16.94 }
16.95 void nextIn(Arc &e) const {
16.96 - e.id=arcs[e.id].next_in;
16.97 + e.id=_arcs[e.id].next_in;
16.98 }
16.99
16.100
16.101 @@ -159,32 +159,32 @@
16.102 static Arc arcFromId(int id) { return Arc(id);}
16.103
16.104 bool valid(Node n) const {
16.105 - return n.id >= 0 && n.id < static_cast<int>(nodes.size()) &&
16.106 - nodes[n.id].prev != -2;
16.107 + return n.id >= 0 && n.id < static_cast<int>(_nodes.size()) &&
16.108 + _nodes[n.id].prev != -2;
16.109 }
16.110
16.111 bool valid(Arc a) const {
16.112 - return a.id >= 0 && a.id < static_cast<int>(arcs.size()) &&
16.113 - arcs[a.id].prev_in != -2;
16.114 + return a.id >= 0 && a.id < static_cast<int>(_arcs.size()) &&
16.115 + _arcs[a.id].prev_in != -2;
16.116 }
16.117
16.118 Node addNode() {
16.119 int n;
16.120
16.121 if(first_free_node==-1) {
16.122 - n = nodes.size();
16.123 - nodes.push_back(NodeT());
16.124 + n = _nodes.size();
16.125 + _nodes.push_back(NodeT());
16.126 } else {
16.127 n = first_free_node;
16.128 - first_free_node = nodes[n].next;
16.129 + first_free_node = _nodes[n].next;
16.130 }
16.131
16.132 - nodes[n].next = first_node;
16.133 - if(first_node != -1) nodes[first_node].prev = n;
16.134 + _nodes[n].next = first_node;
16.135 + if(first_node != -1) _nodes[first_node].prev = n;
16.136 first_node = n;
16.137 - nodes[n].prev = -1;
16.138 -
16.139 - nodes[n].first_in = nodes[n].first_out = -1;
16.140 + _nodes[n].prev = -1;
16.141 +
16.142 + _nodes[n].first_in = _nodes[n].first_out = -1;
16.143
16.144 return Node(n);
16.145 }
16.146 @@ -193,29 +193,29 @@
16.147 int n;
16.148
16.149 if (first_free_arc == -1) {
16.150 - n = arcs.size();
16.151 - arcs.push_back(ArcT());
16.152 + n = _arcs.size();
16.153 + _arcs.push_back(ArcT());
16.154 } else {
16.155 n = first_free_arc;
16.156 - first_free_arc = arcs[n].next_in;
16.157 + first_free_arc = _arcs[n].next_in;
16.158 }
16.159
16.160 - arcs[n].source = u.id;
16.161 - arcs[n].target = v.id;
16.162 -
16.163 - arcs[n].next_out = nodes[u.id].first_out;
16.164 - if(nodes[u.id].first_out != -1) {
16.165 - arcs[nodes[u.id].first_out].prev_out = n;
16.166 + _arcs[n].source = u.id;
16.167 + _arcs[n].target = v.id;
16.168 +
16.169 + _arcs[n].next_out = _nodes[u.id].first_out;
16.170 + if(_nodes[u.id].first_out != -1) {
16.171 + _arcs[_nodes[u.id].first_out].prev_out = n;
16.172 }
16.173
16.174 - arcs[n].next_in = nodes[v.id].first_in;
16.175 - if(nodes[v.id].first_in != -1) {
16.176 - arcs[nodes[v.id].first_in].prev_in = n;
16.177 + _arcs[n].next_in = _nodes[v.id].first_in;
16.178 + if(_nodes[v.id].first_in != -1) {
16.179 + _arcs[_nodes[v.id].first_in].prev_in = n;
16.180 }
16.181
16.182 - arcs[n].prev_in = arcs[n].prev_out = -1;
16.183 -
16.184 - nodes[u.id].first_out = nodes[v.id].first_in = n;
16.185 + _arcs[n].prev_in = _arcs[n].prev_out = -1;
16.186 +
16.187 + _nodes[u.id].first_out = _nodes[v.id].first_in = n;
16.188
16.189 return Arc(n);
16.190 }
16.191 @@ -223,87 +223,87 @@
16.192 void erase(const Node& node) {
16.193 int n = node.id;
16.194
16.195 - if(nodes[n].next != -1) {
16.196 - nodes[nodes[n].next].prev = nodes[n].prev;
16.197 + if(_nodes[n].next != -1) {
16.198 + _nodes[_nodes[n].next].prev = _nodes[n].prev;
16.199 }
16.200
16.201 - if(nodes[n].prev != -1) {
16.202 - nodes[nodes[n].prev].next = nodes[n].next;
16.203 + if(_nodes[n].prev != -1) {
16.204 + _nodes[_nodes[n].prev].next = _nodes[n].next;
16.205 } else {
16.206 - first_node = nodes[n].next;
16.207 + first_node = _nodes[n].next;
16.208 }
16.209
16.210 - nodes[n].next = first_free_node;
16.211 + _nodes[n].next = first_free_node;
16.212 first_free_node = n;
16.213 - nodes[n].prev = -2;
16.214 + _nodes[n].prev = -2;
16.215
16.216 }
16.217
16.218 void erase(const Arc& arc) {
16.219 int n = arc.id;
16.220
16.221 - if(arcs[n].next_in!=-1) {
16.222 - arcs[arcs[n].next_in].prev_in = arcs[n].prev_in;
16.223 + if(_arcs[n].next_in!=-1) {
16.224 + _arcs[_arcs[n].next_in].prev_in = _arcs[n].prev_in;
16.225 }
16.226
16.227 - if(arcs[n].prev_in!=-1) {
16.228 - arcs[arcs[n].prev_in].next_in = arcs[n].next_in;
16.229 + if(_arcs[n].prev_in!=-1) {
16.230 + _arcs[_arcs[n].prev_in].next_in = _arcs[n].next_in;
16.231 } else {
16.232 - nodes[arcs[n].target].first_in = arcs[n].next_in;
16.233 + _nodes[_arcs[n].target].first_in = _arcs[n].next_in;
16.234 }
16.235
16.236
16.237 - if(arcs[n].next_out!=-1) {
16.238 - arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
16.239 + if(_arcs[n].next_out!=-1) {
16.240 + _arcs[_arcs[n].next_out].prev_out = _arcs[n].prev_out;
16.241 }
16.242
16.243 - if(arcs[n].prev_out!=-1) {
16.244 - arcs[arcs[n].prev_out].next_out = arcs[n].next_out;
16.245 + if(_arcs[n].prev_out!=-1) {
16.246 + _arcs[_arcs[n].prev_out].next_out = _arcs[n].next_out;
16.247 } else {
16.248 - nodes[arcs[n].source].first_out = arcs[n].next_out;
16.249 + _nodes[_arcs[n].source].first_out = _arcs[n].next_out;
16.250 }
16.251
16.252 - arcs[n].next_in = first_free_arc;
16.253 + _arcs[n].next_in = first_free_arc;
16.254 first_free_arc = n;
16.255 - arcs[n].prev_in = -2;
16.256 + _arcs[n].prev_in = -2;
16.257 }
16.258
16.259 void clear() {
16.260 - arcs.clear();
16.261 - nodes.clear();
16.262 + _arcs.clear();
16.263 + _nodes.clear();
16.264 first_node = first_free_node = first_free_arc = -1;
16.265 }
16.266
16.267 protected:
16.268 void changeTarget(Arc e, Node n)
16.269 {
16.270 - if(arcs[e.id].next_in != -1)
16.271 - arcs[arcs[e.id].next_in].prev_in = arcs[e.id].prev_in;
16.272 - if(arcs[e.id].prev_in != -1)
16.273 - arcs[arcs[e.id].prev_in].next_in = arcs[e.id].next_in;
16.274 - else nodes[arcs[e.id].target].first_in = arcs[e.id].next_in;
16.275 - if (nodes[n.id].first_in != -1) {
16.276 - arcs[nodes[n.id].first_in].prev_in = e.id;
16.277 + if(_arcs[e.id].next_in != -1)
16.278 + _arcs[_arcs[e.id].next_in].prev_in = _arcs[e.id].prev_in;
16.279 + if(_arcs[e.id].prev_in != -1)
16.280 + _arcs[_arcs[e.id].prev_in].next_in = _arcs[e.id].next_in;
16.281 + else _nodes[_arcs[e.id].target].first_in = _arcs[e.id].next_in;
16.282 + if (_nodes[n.id].first_in != -1) {
16.283 + _arcs[_nodes[n.id].first_in].prev_in = e.id;
16.284 }
16.285 - arcs[e.id].target = n.id;
16.286 - arcs[e.id].prev_in = -1;
16.287 - arcs[e.id].next_in = nodes[n.id].first_in;
16.288 - nodes[n.id].first_in = e.id;
16.289 + _arcs[e.id].target = n.id;
16.290 + _arcs[e.id].prev_in = -1;
16.291 + _arcs[e.id].next_in = _nodes[n.id].first_in;
16.292 + _nodes[n.id].first_in = e.id;
16.293 }
16.294 void changeSource(Arc e, Node n)
16.295 {
16.296 - if(arcs[e.id].next_out != -1)
16.297 - arcs[arcs[e.id].next_out].prev_out = arcs[e.id].prev_out;
16.298 - if(arcs[e.id].prev_out != -1)
16.299 - arcs[arcs[e.id].prev_out].next_out = arcs[e.id].next_out;
16.300 - else nodes[arcs[e.id].source].first_out = arcs[e.id].next_out;
16.301 - if (nodes[n.id].first_out != -1) {
16.302 - arcs[nodes[n.id].first_out].prev_out = e.id;
16.303 + if(_arcs[e.id].next_out != -1)
16.304 + _arcs[_arcs[e.id].next_out].prev_out = _arcs[e.id].prev_out;
16.305 + if(_arcs[e.id].prev_out != -1)
16.306 + _arcs[_arcs[e.id].prev_out].next_out = _arcs[e.id].next_out;
16.307 + else _nodes[_arcs[e.id].source].first_out = _arcs[e.id].next_out;
16.308 + if (_nodes[n.id].first_out != -1) {
16.309 + _arcs[_nodes[n.id].first_out].prev_out = e.id;
16.310 }
16.311 - arcs[e.id].source = n.id;
16.312 - arcs[e.id].prev_out = -1;
16.313 - arcs[e.id].next_out = nodes[n.id].first_out;
16.314 - nodes[n.id].first_out = e.id;
16.315 + _arcs[e.id].source = n.id;
16.316 + _arcs[e.id].prev_out = -1;
16.317 + _arcs[e.id].next_out = _nodes[n.id].first_out;
16.318 + _nodes[n.id].first_out = e.id;
16.319 }
16.320
16.321 };
16.322 @@ -486,10 +486,10 @@
16.323 ///Snapshot feature.
16.324 Node split(Node n, bool connect = true) {
16.325 Node b = addNode();
16.326 - nodes[b.id].first_out=nodes[n.id].first_out;
16.327 - nodes[n.id].first_out=-1;
16.328 - for(int i=nodes[b.id].first_out; i!=-1; i=arcs[i].next_out) {
16.329 - arcs[i].source=b.id;
16.330 + _nodes[b.id].first_out=_nodes[n.id].first_out;
16.331 + _nodes[n.id].first_out=-1;
16.332 + for(int i=_nodes[b.id].first_out; i!=-1; i=_arcs[i].next_out) {
16.333 + _arcs[i].source=b.id;
16.334 }
16.335 if (connect) addArc(n,b);
16.336 return b;
16.337 @@ -532,7 +532,7 @@
16.338 /// then it is worth reserving space for this amount before starting
16.339 /// to build the digraph.
16.340 /// \sa reserveArc()
16.341 - void reserveNode(int n) { nodes.reserve(n); };
16.342 + void reserveNode(int n) { _nodes.reserve(n); };
16.343
16.344 /// Reserve memory for arcs.
16.345
16.346 @@ -542,7 +542,7 @@
16.347 /// then it is worth reserving space for this amount before starting
16.348 /// to build the digraph.
16.349 /// \sa reserveNode()
16.350 - void reserveArc(int m) { arcs.reserve(m); };
16.351 + void reserveArc(int m) { _arcs.reserve(m); };
16.352
16.353 /// \brief Class to make a snapshot of the digraph and restore
16.354 /// it later.
16.355 @@ -803,13 +803,13 @@
16.356 int prev_out, next_out;
16.357 };
16.358
16.359 - std::vector<NodeT> nodes;
16.360 + std::vector<NodeT> _nodes;
16.361
16.362 int first_node;
16.363
16.364 int first_free_node;
16.365
16.366 - std::vector<ArcT> arcs;
16.367 + std::vector<ArcT> _arcs;
16.368
16.369 int first_free_arc;
16.370
16.371 @@ -867,19 +867,19 @@
16.372 };
16.373
16.374 ListGraphBase()
16.375 - : nodes(), first_node(-1),
16.376 - first_free_node(-1), arcs(), first_free_arc(-1) {}
16.377 -
16.378 -
16.379 - int maxNodeId() const { return nodes.size()-1; }
16.380 - int maxEdgeId() const { return arcs.size() / 2 - 1; }
16.381 - int maxArcId() const { return arcs.size()-1; }
16.382 -
16.383 - Node source(Arc e) const { return Node(arcs[e.id ^ 1].target); }
16.384 - Node target(Arc e) const { return Node(arcs[e.id].target); }
16.385 -
16.386 - Node u(Edge e) const { return Node(arcs[2 * e.id].target); }
16.387 - Node v(Edge e) const { return Node(arcs[2 * e.id + 1].target); }
16.388 + : _nodes(), first_node(-1),
16.389 + first_free_node(-1), _arcs(), first_free_arc(-1) {}
16.390 +
16.391 +
16.392 + int maxNodeId() const { return _nodes.size()-1; }
16.393 + int maxEdgeId() const { return _arcs.size() / 2 - 1; }
16.394 + int maxArcId() const { return _arcs.size()-1; }
16.395 +
16.396 + Node source(Arc e) const { return Node(_arcs[e.id ^ 1].target); }
16.397 + Node target(Arc e) const { return Node(_arcs[e.id].target); }
16.398 +
16.399 + Node u(Edge e) const { return Node(_arcs[2 * e.id].target); }
16.400 + Node v(Edge e) const { return Node(_arcs[2 * e.id + 1].target); }
16.401
16.402 static bool direction(Arc e) {
16.403 return (e.id & 1) == 1;
16.404 @@ -894,88 +894,88 @@
16.405 }
16.406
16.407 void next(Node& node) const {
16.408 - node.id = nodes[node.id].next;
16.409 + node.id = _nodes[node.id].next;
16.410 }
16.411
16.412 void first(Arc& e) const {
16.413 int n = first_node;
16.414 - while (n != -1 && nodes[n].first_out == -1) {
16.415 - n = nodes[n].next;
16.416 + while (n != -1 && _nodes[n].first_out == -1) {
16.417 + n = _nodes[n].next;
16.418 }
16.419 - e.id = (n == -1) ? -1 : nodes[n].first_out;
16.420 + e.id = (n == -1) ? -1 : _nodes[n].first_out;
16.421 }
16.422
16.423 void next(Arc& e) const {
16.424 - if (arcs[e.id].next_out != -1) {
16.425 - e.id = arcs[e.id].next_out;
16.426 + if (_arcs[e.id].next_out != -1) {
16.427 + e.id = _arcs[e.id].next_out;
16.428 } else {
16.429 - int n = nodes[arcs[e.id ^ 1].target].next;
16.430 - while(n != -1 && nodes[n].first_out == -1) {
16.431 - n = nodes[n].next;
16.432 + int n = _nodes[_arcs[e.id ^ 1].target].next;
16.433 + while(n != -1 && _nodes[n].first_out == -1) {
16.434 + n = _nodes[n].next;
16.435 }
16.436 - e.id = (n == -1) ? -1 : nodes[n].first_out;
16.437 + e.id = (n == -1) ? -1 : _nodes[n].first_out;
16.438 }
16.439 }
16.440
16.441 void first(Edge& e) const {
16.442 int n = first_node;
16.443 while (n != -1) {
16.444 - e.id = nodes[n].first_out;
16.445 + e.id = _nodes[n].first_out;
16.446 while ((e.id & 1) != 1) {
16.447 - e.id = arcs[e.id].next_out;
16.448 + e.id = _arcs[e.id].next_out;
16.449 }
16.450 if (e.id != -1) {
16.451 e.id /= 2;
16.452 return;
16.453 }
16.454 - n = nodes[n].next;
16.455 + n = _nodes[n].next;
16.456 }
16.457 e.id = -1;
16.458 }
16.459
16.460 void next(Edge& e) const {
16.461 - int n = arcs[e.id * 2].target;
16.462 - e.id = arcs[(e.id * 2) | 1].next_out;
16.463 + int n = _arcs[e.id * 2].target;
16.464 + e.id = _arcs[(e.id * 2) | 1].next_out;
16.465 while ((e.id & 1) != 1) {
16.466 - e.id = arcs[e.id].next_out;
16.467 + e.id = _arcs[e.id].next_out;
16.468 }
16.469 if (e.id != -1) {
16.470 e.id /= 2;
16.471 return;
16.472 }
16.473 - n = nodes[n].next;
16.474 + n = _nodes[n].next;
16.475 while (n != -1) {
16.476 - e.id = nodes[n].first_out;
16.477 + e.id = _nodes[n].first_out;
16.478 while ((e.id & 1) != 1) {
16.479 - e.id = arcs[e.id].next_out;
16.480 + e.id = _arcs[e.id].next_out;
16.481 }
16.482 if (e.id != -1) {
16.483 e.id /= 2;
16.484 return;
16.485 }
16.486 - n = nodes[n].next;
16.487 + n = _nodes[n].next;
16.488 }
16.489 e.id = -1;
16.490 }
16.491
16.492 void firstOut(Arc &e, const Node& v) const {
16.493 - e.id = nodes[v.id].first_out;
16.494 + e.id = _nodes[v.id].first_out;
16.495 }
16.496 void nextOut(Arc &e) const {
16.497 - e.id = arcs[e.id].next_out;
16.498 + e.id = _arcs[e.id].next_out;
16.499 }
16.500
16.501 void firstIn(Arc &e, const Node& v) const {
16.502 - e.id = ((nodes[v.id].first_out) ^ 1);
16.503 + e.id = ((_nodes[v.id].first_out) ^ 1);
16.504 if (e.id == -2) e.id = -1;
16.505 }
16.506 void nextIn(Arc &e) const {
16.507 - e.id = ((arcs[e.id ^ 1].next_out) ^ 1);
16.508 + e.id = ((_arcs[e.id ^ 1].next_out) ^ 1);
16.509 if (e.id == -2) e.id = -1;
16.510 }
16.511
16.512 void firstInc(Edge &e, bool& d, const Node& v) const {
16.513 - int a = nodes[v.id].first_out;
16.514 + int a = _nodes[v.id].first_out;
16.515 if (a != -1 ) {
16.516 e.id = a / 2;
16.517 d = ((a & 1) == 1);
16.518 @@ -985,7 +985,7 @@
16.519 }
16.520 }
16.521 void nextInc(Edge &e, bool& d) const {
16.522 - int a = (arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
16.523 + int a = (_arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
16.524 if (a != -1 ) {
16.525 e.id = a / 2;
16.526 d = ((a & 1) == 1);
16.527 @@ -1004,37 +1004,37 @@
16.528 static Edge edgeFromId(int id) { return Edge(id);}
16.529
16.530 bool valid(Node n) const {
16.531 - return n.id >= 0 && n.id < static_cast<int>(nodes.size()) &&
16.532 - nodes[n.id].prev != -2;
16.533 + return n.id >= 0 && n.id < static_cast<int>(_nodes.size()) &&
16.534 + _nodes[n.id].prev != -2;
16.535 }
16.536
16.537 bool valid(Arc a) const {
16.538 - return a.id >= 0 && a.id < static_cast<int>(arcs.size()) &&
16.539 - arcs[a.id].prev_out != -2;
16.540 + return a.id >= 0 && a.id < static_cast<int>(_arcs.size()) &&
16.541 + _arcs[a.id].prev_out != -2;
16.542 }
16.543
16.544 bool valid(Edge e) const {
16.545 - return e.id >= 0 && 2 * e.id < static_cast<int>(arcs.size()) &&
16.546 - arcs[2 * e.id].prev_out != -2;
16.547 + return e.id >= 0 && 2 * e.id < static_cast<int>(_arcs.size()) &&
16.548 + _arcs[2 * e.id].prev_out != -2;
16.549 }
16.550
16.551 Node addNode() {
16.552 int n;
16.553
16.554 if(first_free_node==-1) {
16.555 - n = nodes.size();
16.556 - nodes.push_back(NodeT());
16.557 + n = _nodes.size();
16.558 + _nodes.push_back(NodeT());
16.559 } else {
16.560 n = first_free_node;
16.561 - first_free_node = nodes[n].next;
16.562 + first_free_node = _nodes[n].next;
16.563 }
16.564
16.565 - nodes[n].next = first_node;
16.566 - if (first_node != -1) nodes[first_node].prev = n;
16.567 + _nodes[n].next = first_node;
16.568 + if (first_node != -1) _nodes[first_node].prev = n;
16.569 first_node = n;
16.570 - nodes[n].prev = -1;
16.571 -
16.572 - nodes[n].first_out = -1;
16.573 + _nodes[n].prev = -1;
16.574 +
16.575 + _nodes[n].first_out = -1;
16.576
16.577 return Node(n);
16.578 }
16.579 @@ -1043,30 +1043,30 @@
16.580 int n;
16.581
16.582 if (first_free_arc == -1) {
16.583 - n = arcs.size();
16.584 - arcs.push_back(ArcT());
16.585 - arcs.push_back(ArcT());
16.586 + n = _arcs.size();
16.587 + _arcs.push_back(ArcT());
16.588 + _arcs.push_back(ArcT());
16.589 } else {
16.590 n = first_free_arc;
16.591 - first_free_arc = arcs[n].next_out;
16.592 + first_free_arc = _arcs[n].next_out;
16.593 }
16.594
16.595 - arcs[n].target = u.id;
16.596 - arcs[n | 1].target = v.id;
16.597 -
16.598 - arcs[n].next_out = nodes[v.id].first_out;
16.599 - if (nodes[v.id].first_out != -1) {
16.600 - arcs[nodes[v.id].first_out].prev_out = n;
16.601 + _arcs[n].target = u.id;
16.602 + _arcs[n | 1].target = v.id;
16.603 +
16.604 + _arcs[n].next_out = _nodes[v.id].first_out;
16.605 + if (_nodes[v.id].first_out != -1) {
16.606 + _arcs[_nodes[v.id].first_out].prev_out = n;
16.607 }
16.608 - arcs[n].prev_out = -1;
16.609 - nodes[v.id].first_out = n;
16.610 -
16.611 - arcs[n | 1].next_out = nodes[u.id].first_out;
16.612 - if (nodes[u.id].first_out != -1) {
16.613 - arcs[nodes[u.id].first_out].prev_out = (n | 1);
16.614 + _arcs[n].prev_out = -1;
16.615 + _nodes[v.id].first_out = n;
16.616 +
16.617 + _arcs[n | 1].next_out = _nodes[u.id].first_out;
16.618 + if (_nodes[u.id].first_out != -1) {
16.619 + _arcs[_nodes[u.id].first_out].prev_out = (n | 1);
16.620 }
16.621 - arcs[n | 1].prev_out = -1;
16.622 - nodes[u.id].first_out = (n | 1);
16.623 + _arcs[n | 1].prev_out = -1;
16.624 + _nodes[u.id].first_out = (n | 1);
16.625
16.626 return Edge(n / 2);
16.627 }
16.628 @@ -1074,100 +1074,100 @@
16.629 void erase(const Node& node) {
16.630 int n = node.id;
16.631
16.632 - if(nodes[n].next != -1) {
16.633 - nodes[nodes[n].next].prev = nodes[n].prev;
16.634 + if(_nodes[n].next != -1) {
16.635 + _nodes[_nodes[n].next].prev = _nodes[n].prev;
16.636 }
16.637
16.638 - if(nodes[n].prev != -1) {
16.639 - nodes[nodes[n].prev].next = nodes[n].next;
16.640 + if(_nodes[n].prev != -1) {
16.641 + _nodes[_nodes[n].prev].next = _nodes[n].next;
16.642 } else {
16.643 - first_node = nodes[n].next;
16.644 + first_node = _nodes[n].next;
16.645 }
16.646
16.647 - nodes[n].next = first_free_node;
16.648 + _nodes[n].next = first_free_node;
16.649 first_free_node = n;
16.650 - nodes[n].prev = -2;
16.651 + _nodes[n].prev = -2;
16.652 }
16.653
16.654 void erase(const Edge& edge) {
16.655 int n = edge.id * 2;
16.656
16.657 - if (arcs[n].next_out != -1) {
16.658 - arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
16.659 + if (_arcs[n].next_out != -1) {
16.660 + _arcs[_arcs[n].next_out].prev_out = _arcs[n].prev_out;
16.661 }
16.662
16.663 - if (arcs[n].prev_out != -1) {
16.664 - arcs[arcs[n].prev_out].next_out = arcs[n].next_out;
16.665 + if (_arcs[n].prev_out != -1) {
16.666 + _arcs[_arcs[n].prev_out].next_out = _arcs[n].next_out;
16.667 } else {
16.668 - nodes[arcs[n | 1].target].first_out = arcs[n].next_out;
16.669 + _nodes[_arcs[n | 1].target].first_out = _arcs[n].next_out;
16.670 }
16.671
16.672 - if (arcs[n | 1].next_out != -1) {
16.673 - arcs[arcs[n | 1].next_out].prev_out = arcs[n | 1].prev_out;
16.674 + if (_arcs[n | 1].next_out != -1) {
16.675 + _arcs[_arcs[n | 1].next_out].prev_out = _arcs[n | 1].prev_out;
16.676 }
16.677
16.678 - if (arcs[n | 1].prev_out != -1) {
16.679 - arcs[arcs[n | 1].prev_out].next_out = arcs[n | 1].next_out;
16.680 + if (_arcs[n | 1].prev_out != -1) {
16.681 + _arcs[_arcs[n | 1].prev_out].next_out = _arcs[n | 1].next_out;
16.682 } else {
16.683 - nodes[arcs[n].target].first_out = arcs[n | 1].next_out;
16.684 + _nodes[_arcs[n].target].first_out = _arcs[n | 1].next_out;
16.685 }
16.686
16.687 - arcs[n].next_out = first_free_arc;
16.688 + _arcs[n].next_out = first_free_arc;
16.689 first_free_arc = n;
16.690 - arcs[n].prev_out = -2;
16.691 - arcs[n | 1].prev_out = -2;
16.692 + _arcs[n].prev_out = -2;
16.693 + _arcs[n | 1].prev_out = -2;
16.694
16.695 }
16.696
16.697 void clear() {
16.698 - arcs.clear();
16.699 - nodes.clear();
16.700 + _arcs.clear();
16.701 + _nodes.clear();
16.702 first_node = first_free_node = first_free_arc = -1;
16.703 }
16.704
16.705 protected:
16.706
16.707 void changeV(Edge e, Node n) {
16.708 - if(arcs[2 * e.id].next_out != -1) {
16.709 - arcs[arcs[2 * e.id].next_out].prev_out = arcs[2 * e.id].prev_out;
16.710 + if(_arcs[2 * e.id].next_out != -1) {
16.711 + _arcs[_arcs[2 * e.id].next_out].prev_out = _arcs[2 * e.id].prev_out;
16.712 }
16.713 - if(arcs[2 * e.id].prev_out != -1) {
16.714 - arcs[arcs[2 * e.id].prev_out].next_out =
16.715 - arcs[2 * e.id].next_out;
16.716 + if(_arcs[2 * e.id].prev_out != -1) {
16.717 + _arcs[_arcs[2 * e.id].prev_out].next_out =
16.718 + _arcs[2 * e.id].next_out;
16.719 } else {
16.720 - nodes[arcs[(2 * e.id) | 1].target].first_out =
16.721 - arcs[2 * e.id].next_out;
16.722 + _nodes[_arcs[(2 * e.id) | 1].target].first_out =
16.723 + _arcs[2 * e.id].next_out;
16.724 }
16.725
16.726 - if (nodes[n.id].first_out != -1) {
16.727 - arcs[nodes[n.id].first_out].prev_out = 2 * e.id;
16.728 + if (_nodes[n.id].first_out != -1) {
16.729 + _arcs[_nodes[n.id].first_out].prev_out = 2 * e.id;
16.730 }
16.731 - arcs[(2 * e.id) | 1].target = n.id;
16.732 - arcs[2 * e.id].prev_out = -1;
16.733 - arcs[2 * e.id].next_out = nodes[n.id].first_out;
16.734 - nodes[n.id].first_out = 2 * e.id;
16.735 + _arcs[(2 * e.id) | 1].target = n.id;
16.736 + _arcs[2 * e.id].prev_out = -1;
16.737 + _arcs[2 * e.id].next_out = _nodes[n.id].first_out;
16.738 + _nodes[n.id].first_out = 2 * e.id;
16.739 }
16.740
16.741 void changeU(Edge e, Node n) {
16.742 - if(arcs[(2 * e.id) | 1].next_out != -1) {
16.743 - arcs[arcs[(2 * e.id) | 1].next_out].prev_out =
16.744 - arcs[(2 * e.id) | 1].prev_out;
16.745 + if(_arcs[(2 * e.id) | 1].next_out != -1) {
16.746 + _arcs[_arcs[(2 * e.id) | 1].next_out].prev_out =
16.747 + _arcs[(2 * e.id) | 1].prev_out;
16.748 }
16.749 - if(arcs[(2 * e.id) | 1].prev_out != -1) {
16.750 - arcs[arcs[(2 * e.id) | 1].prev_out].next_out =
16.751 - arcs[(2 * e.id) | 1].next_out;
16.752 + if(_arcs[(2 * e.id) | 1].prev_out != -1) {
16.753 + _arcs[_arcs[(2 * e.id) | 1].prev_out].next_out =
16.754 + _arcs[(2 * e.id) | 1].next_out;
16.755 } else {
16.756 - nodes[arcs[2 * e.id].target].first_out =
16.757 - arcs[(2 * e.id) | 1].next_out;
16.758 + _nodes[_arcs[2 * e.id].target].first_out =
16.759 + _arcs[(2 * e.id) | 1].next_out;
16.760 }
16.761
16.762 - if (nodes[n.id].first_out != -1) {
16.763 - arcs[nodes[n.id].first_out].prev_out = ((2 * e.id) | 1);
16.764 + if (_nodes[n.id].first_out != -1) {
16.765 + _arcs[_nodes[n.id].first_out].prev_out = ((2 * e.id) | 1);
16.766 }
16.767 - arcs[2 * e.id].target = n.id;
16.768 - arcs[(2 * e.id) | 1].prev_out = -1;
16.769 - arcs[(2 * e.id) | 1].next_out = nodes[n.id].first_out;
16.770 - nodes[n.id].first_out = ((2 * e.id) | 1);
16.771 + _arcs[2 * e.id].target = n.id;
16.772 + _arcs[(2 * e.id) | 1].prev_out = -1;
16.773 + _arcs[(2 * e.id) | 1].next_out = _nodes[n.id].first_out;
16.774 + _nodes[n.id].first_out = ((2 * e.id) | 1);
16.775 }
16.776
16.777 };
16.778 @@ -1344,7 +1344,7 @@
16.779 /// then it is worth reserving space for this amount before starting
16.780 /// to build the graph.
16.781 /// \sa reserveEdge()
16.782 - void reserveNode(int n) { nodes.reserve(n); };
16.783 + void reserveNode(int n) { _nodes.reserve(n); };
16.784
16.785 /// Reserve memory for edges.
16.786
16.787 @@ -1354,7 +1354,7 @@
16.788 /// then it is worth reserving space for this amount before starting
16.789 /// to build the graph.
16.790 /// \sa reserveNode()
16.791 - void reserveEdge(int m) { arcs.reserve(2 * m); };
16.792 + void reserveEdge(int m) { _arcs.reserve(2 * m); };
16.793
16.794 /// \brief Class to make a snapshot of the graph and restore
16.795 /// it later.
16.796 @@ -1617,14 +1617,14 @@
16.797 int prev_out, next_out;
16.798 };
16.799
16.800 - std::vector<NodeT> nodes;
16.801 + std::vector<NodeT> _nodes;
16.802
16.803 int first_node, first_red, first_blue;
16.804 int max_red, max_blue;
16.805
16.806 int first_free_red, first_free_blue;
16.807
16.808 - std::vector<ArcT> arcs;
16.809 + std::vector<ArcT> _arcs;
16.810
16.811 int first_free_arc;
16.812
16.813 @@ -1706,33 +1706,33 @@
16.814 };
16.815
16.816 ListBpGraphBase()
16.817 - : nodes(), first_node(-1),
16.818 + : _nodes(), first_node(-1),
16.819 first_red(-1), first_blue(-1),
16.820 max_red(-1), max_blue(-1),
16.821 first_free_red(-1), first_free_blue(-1),
16.822 - arcs(), first_free_arc(-1) {}
16.823 -
16.824 -
16.825 - bool red(Node n) const { return nodes[n.id].red; }
16.826 - bool blue(Node n) const { return !nodes[n.id].red; }
16.827 + _arcs(), first_free_arc(-1) {}
16.828 +
16.829 +
16.830 + bool red(Node n) const { return _nodes[n.id].red; }
16.831 + bool blue(Node n) const { return !_nodes[n.id].red; }
16.832
16.833 static RedNode asRedNodeUnsafe(Node n) { return RedNode(n.id); }
16.834 static BlueNode asBlueNodeUnsafe(Node n) { return BlueNode(n.id); }
16.835
16.836 - int maxNodeId() const { return nodes.size()-1; }
16.837 + int maxNodeId() const { return _nodes.size()-1; }
16.838 int maxRedId() const { return max_red; }
16.839 int maxBlueId() const { return max_blue; }
16.840 - int maxEdgeId() const { return arcs.size() / 2 - 1; }
16.841 - int maxArcId() const { return arcs.size()-1; }
16.842 -
16.843 - Node source(Arc e) const { return Node(arcs[e.id ^ 1].target); }
16.844 - Node target(Arc e) const { return Node(arcs[e.id].target); }
16.845 + int maxEdgeId() const { return _arcs.size() / 2 - 1; }
16.846 + int maxArcId() const { return _arcs.size()-1; }
16.847 +
16.848 + Node source(Arc e) const { return Node(_arcs[e.id ^ 1].target); }
16.849 + Node target(Arc e) const { return Node(_arcs[e.id].target); }
16.850
16.851 RedNode redNode(Edge e) const {
16.852 - return RedNode(arcs[2 * e.id].target);
16.853 + return RedNode(_arcs[2 * e.id].target);
16.854 }
16.855 BlueNode blueNode(Edge e) const {
16.856 - return BlueNode(arcs[2 * e.id + 1].target);
16.857 + return BlueNode(_arcs[2 * e.id + 1].target);
16.858 }
16.859
16.860 static bool direction(Arc e) {
16.861 @@ -1748,7 +1748,7 @@
16.862 }
16.863
16.864 void next(Node& node) const {
16.865 - node.id = nodes[node.id].next;
16.866 + node.id = _nodes[node.id].next;
16.867 }
16.868
16.869 void first(RedNode& node) const {
16.870 @@ -1756,7 +1756,7 @@
16.871 }
16.872
16.873 void next(RedNode& node) const {
16.874 - node.id = nodes[node.id].partition_next;
16.875 + node.id = _nodes[node.id].partition_next;
16.876 }
16.877
16.878 void first(BlueNode& node) const {
16.879 @@ -1764,88 +1764,88 @@
16.880 }
16.881
16.882 void next(BlueNode& node) const {
16.883 - node.id = nodes[node.id].partition_next;
16.884 + node.id = _nodes[node.id].partition_next;
16.885 }
16.886
16.887 void first(Arc& e) const {
16.888 int n = first_node;
16.889 - while (n != -1 && nodes[n].first_out == -1) {
16.890 - n = nodes[n].next;
16.891 + while (n != -1 && _nodes[n].first_out == -1) {
16.892 + n = _nodes[n].next;
16.893 }
16.894 - e.id = (n == -1) ? -1 : nodes[n].first_out;
16.895 + e.id = (n == -1) ? -1 : _nodes[n].first_out;
16.896 }
16.897
16.898 void next(Arc& e) const {
16.899 - if (arcs[e.id].next_out != -1) {
16.900 - e.id = arcs[e.id].next_out;
16.901 + if (_arcs[e.id].next_out != -1) {
16.902 + e.id = _arcs[e.id].next_out;
16.903 } else {
16.904 - int n = nodes[arcs[e.id ^ 1].target].next;
16.905 - while(n != -1 && nodes[n].first_out == -1) {
16.906 - n = nodes[n].next;
16.907 + int n = _nodes[_arcs[e.id ^ 1].target].next;
16.908 + while(n != -1 && _nodes[n].first_out == -1) {
16.909 + n = _nodes[n].next;
16.910 }
16.911 - e.id = (n == -1) ? -1 : nodes[n].first_out;
16.912 + e.id = (n == -1) ? -1 : _nodes[n].first_out;
16.913 }
16.914 }
16.915
16.916 void first(Edge& e) const {
16.917 int n = first_node;
16.918 while (n != -1) {
16.919 - e.id = nodes[n].first_out;
16.920 + e.id = _nodes[n].first_out;
16.921 while ((e.id & 1) != 1) {
16.922 - e.id = arcs[e.id].next_out;
16.923 + e.id = _arcs[e.id].next_out;
16.924 }
16.925 if (e.id != -1) {
16.926 e.id /= 2;
16.927 return;
16.928 }
16.929 - n = nodes[n].next;
16.930 + n = _nodes[n].next;
16.931 }
16.932 e.id = -1;
16.933 }
16.934
16.935 void next(Edge& e) const {
16.936 - int n = arcs[e.id * 2].target;
16.937 - e.id = arcs[(e.id * 2) | 1].next_out;
16.938 + int n = _arcs[e.id * 2].target;
16.939 + e.id = _arcs[(e.id * 2) | 1].next_out;
16.940 while ((e.id & 1) != 1) {
16.941 - e.id = arcs[e.id].next_out;
16.942 + e.id = _arcs[e.id].next_out;
16.943 }
16.944 if (e.id != -1) {
16.945 e.id /= 2;
16.946 return;
16.947 }
16.948 - n = nodes[n].next;
16.949 + n = _nodes[n].next;
16.950 while (n != -1) {
16.951 - e.id = nodes[n].first_out;
16.952 + e.id = _nodes[n].first_out;
16.953 while ((e.id & 1) != 1) {
16.954 - e.id = arcs[e.id].next_out;
16.955 + e.id = _arcs[e.id].next_out;
16.956 }
16.957 if (e.id != -1) {
16.958 e.id /= 2;
16.959 return;
16.960 }
16.961 - n = nodes[n].next;
16.962 + n = _nodes[n].next;
16.963 }
16.964 e.id = -1;
16.965 }
16.966
16.967 void firstOut(Arc &e, const Node& v) const {
16.968 - e.id = nodes[v.id].first_out;
16.969 + e.id = _nodes[v.id].first_out;
16.970 }
16.971 void nextOut(Arc &e) const {
16.972 - e.id = arcs[e.id].next_out;
16.973 + e.id = _arcs[e.id].next_out;
16.974 }
16.975
16.976 void firstIn(Arc &e, const Node& v) const {
16.977 - e.id = ((nodes[v.id].first_out) ^ 1);
16.978 + e.id = ((_nodes[v.id].first_out) ^ 1);
16.979 if (e.id == -2) e.id = -1;
16.980 }
16.981 void nextIn(Arc &e) const {
16.982 - e.id = ((arcs[e.id ^ 1].next_out) ^ 1);
16.983 + e.id = ((_arcs[e.id ^ 1].next_out) ^ 1);
16.984 if (e.id == -2) e.id = -1;
16.985 }
16.986
16.987 void firstInc(Edge &e, bool& d, const Node& v) const {
16.988 - int a = nodes[v.id].first_out;
16.989 + int a = _nodes[v.id].first_out;
16.990 if (a != -1 ) {
16.991 e.id = a / 2;
16.992 d = ((a & 1) == 1);
16.993 @@ -1855,7 +1855,7 @@
16.994 }
16.995 }
16.996 void nextInc(Edge &e, bool& d) const {
16.997 - int a = (arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
16.998 + int a = (_arcs[(e.id * 2) | (d ? 1 : 0)].next_out);
16.999 if (a != -1 ) {
16.1000 e.id = a / 2;
16.1001 d = ((a & 1) == 1);
16.1002 @@ -1866,8 +1866,8 @@
16.1003 }
16.1004
16.1005 static int id(Node v) { return v.id; }
16.1006 - int id(RedNode v) const { return nodes[v.id].partition_index; }
16.1007 - int id(BlueNode v) const { return nodes[v.id].partition_index; }
16.1008 + int id(RedNode v) const { return _nodes[v.id].partition_index; }
16.1009 + int id(BlueNode v) const { return _nodes[v.id].partition_index; }
16.1010 static int id(Arc e) { return e.id; }
16.1011 static int id(Edge e) { return e.id; }
16.1012
16.1013 @@ -1876,44 +1876,44 @@
16.1014 static Edge edgeFromId(int id) { return Edge(id);}
16.1015
16.1016 bool valid(Node n) const {
16.1017 - return n.id >= 0 && n.id < static_cast<int>(nodes.size()) &&
16.1018 - nodes[n.id].prev != -2;
16.1019 + return n.id >= 0 && n.id < static_cast<int>(_nodes.size()) &&
16.1020 + _nodes[n.id].prev != -2;
16.1021 }
16.1022
16.1023 bool valid(Arc a) const {
16.1024 - return a.id >= 0 && a.id < static_cast<int>(arcs.size()) &&
16.1025 - arcs[a.id].prev_out != -2;
16.1026 + return a.id >= 0 && a.id < static_cast<int>(_arcs.size()) &&
16.1027 + _arcs[a.id].prev_out != -2;
16.1028 }
16.1029
16.1030 bool valid(Edge e) const {
16.1031 - return e.id >= 0 && 2 * e.id < static_cast<int>(arcs.size()) &&
16.1032 - arcs[2 * e.id].prev_out != -2;
16.1033 + return e.id >= 0 && 2 * e.id < static_cast<int>(_arcs.size()) &&
16.1034 + _arcs[2 * e.id].prev_out != -2;
16.1035 }
16.1036
16.1037 RedNode addRedNode() {
16.1038 int n;
16.1039
16.1040 if(first_free_red==-1) {
16.1041 - n = nodes.size();
16.1042 - nodes.push_back(NodeT());
16.1043 - nodes[n].partition_index = ++max_red;
16.1044 - nodes[n].red = true;
16.1045 + n = _nodes.size();
16.1046 + _nodes.push_back(NodeT());
16.1047 + _nodes[n].partition_index = ++max_red;
16.1048 + _nodes[n].red = true;
16.1049 } else {
16.1050 n = first_free_red;
16.1051 - first_free_red = nodes[n].next;
16.1052 + first_free_red = _nodes[n].next;
16.1053 }
16.1054
16.1055 - nodes[n].next = first_node;
16.1056 - if (first_node != -1) nodes[first_node].prev = n;
16.1057 + _nodes[n].next = first_node;
16.1058 + if (first_node != -1) _nodes[first_node].prev = n;
16.1059 first_node = n;
16.1060 - nodes[n].prev = -1;
16.1061 -
16.1062 - nodes[n].partition_next = first_red;
16.1063 - if (first_red != -1) nodes[first_red].partition_prev = n;
16.1064 + _nodes[n].prev = -1;
16.1065 +
16.1066 + _nodes[n].partition_next = first_red;
16.1067 + if (first_red != -1) _nodes[first_red].partition_prev = n;
16.1068 first_red = n;
16.1069 - nodes[n].partition_prev = -1;
16.1070 -
16.1071 - nodes[n].first_out = -1;
16.1072 + _nodes[n].partition_prev = -1;
16.1073 +
16.1074 + _nodes[n].first_out = -1;
16.1075
16.1076 return RedNode(n);
16.1077 }
16.1078 @@ -1922,26 +1922,26 @@
16.1079 int n;
16.1080
16.1081 if(first_free_blue==-1) {
16.1082 - n = nodes.size();
16.1083 - nodes.push_back(NodeT());
16.1084 - nodes[n].partition_index = ++max_blue;
16.1085 - nodes[n].red = false;
16.1086 + n = _nodes.size();
16.1087 + _nodes.push_back(NodeT());
16.1088 + _nodes[n].partition_index = ++max_blue;
16.1089 + _nodes[n].red = false;
16.1090 } else {
16.1091 n = first_free_blue;
16.1092 - first_free_blue = nodes[n].next;
16.1093 + first_free_blue = _nodes[n].next;
16.1094 }
16.1095
16.1096 - nodes[n].next = first_node;
16.1097 - if (first_node != -1) nodes[first_node].prev = n;
16.1098 + _nodes[n].next = first_node;
16.1099 + if (first_node != -1) _nodes[first_node].prev = n;
16.1100 first_node = n;
16.1101 - nodes[n].prev = -1;
16.1102 -
16.1103 - nodes[n].partition_next = first_blue;
16.1104 - if (first_blue != -1) nodes[first_blue].partition_prev = n;
16.1105 + _nodes[n].prev = -1;
16.1106 +
16.1107 + _nodes[n].partition_next = first_blue;
16.1108 + if (first_blue != -1) _nodes[first_blue].partition_prev = n;
16.1109 first_blue = n;
16.1110 - nodes[n].partition_prev = -1;
16.1111 -
16.1112 - nodes[n].first_out = -1;
16.1113 + _nodes[n].partition_prev = -1;
16.1114 +
16.1115 + _nodes[n].first_out = -1;
16.1116
16.1117 return BlueNode(n);
16.1118 }
16.1119 @@ -1950,30 +1950,30 @@
16.1120 int n;
16.1121
16.1122 if (first_free_arc == -1) {
16.1123 - n = arcs.size();
16.1124 - arcs.push_back(ArcT());
16.1125 - arcs.push_back(ArcT());
16.1126 + n = _arcs.size();
16.1127 + _arcs.push_back(ArcT());
16.1128 + _arcs.push_back(ArcT());
16.1129 } else {
16.1130 n = first_free_arc;
16.1131 - first_free_arc = arcs[n].next_out;
16.1132 + first_free_arc = _arcs[n].next_out;
16.1133 }
16.1134
16.1135 - arcs[n].target = u.id;
16.1136 - arcs[n | 1].target = v.id;
16.1137 -
16.1138 - arcs[n].next_out = nodes[v.id].first_out;
16.1139 - if (nodes[v.id].first_out != -1) {
16.1140 - arcs[nodes[v.id].first_out].prev_out = n;
16.1141 + _arcs[n].target = u.id;
16.1142 + _arcs[n | 1].target = v.id;
16.1143 +
16.1144 + _arcs[n].next_out = _nodes[v.id].first_out;
16.1145 + if (_nodes[v.id].first_out != -1) {
16.1146 + _arcs[_nodes[v.id].first_out].prev_out = n;
16.1147 }
16.1148 - arcs[n].prev_out = -1;
16.1149 - nodes[v.id].first_out = n;
16.1150 -
16.1151 - arcs[n | 1].next_out = nodes[u.id].first_out;
16.1152 - if (nodes[u.id].first_out != -1) {
16.1153 - arcs[nodes[u.id].first_out].prev_out = (n | 1);
16.1154 + _arcs[n].prev_out = -1;
16.1155 + _nodes[v.id].first_out = n;
16.1156 +
16.1157 + _arcs[n | 1].next_out = _nodes[u.id].first_out;
16.1158 + if (_nodes[u.id].first_out != -1) {
16.1159 + _arcs[_nodes[u.id].first_out].prev_out = (n | 1);
16.1160 }
16.1161 - arcs[n | 1].prev_out = -1;
16.1162 - nodes[u.id].first_out = (n | 1);
16.1163 + _arcs[n | 1].prev_out = -1;
16.1164 + _nodes[u.id].first_out = (n | 1);
16.1165
16.1166 return Edge(n / 2);
16.1167 }
16.1168 @@ -1981,73 +1981,73 @@
16.1169 void erase(const Node& node) {
16.1170 int n = node.id;
16.1171
16.1172 - if(nodes[n].next != -1) {
16.1173 - nodes[nodes[n].next].prev = nodes[n].prev;
16.1174 + if(_nodes[n].next != -1) {
16.1175 + _nodes[_nodes[n].next].prev = _nodes[n].prev;
16.1176 }
16.1177
16.1178 - if(nodes[n].prev != -1) {
16.1179 - nodes[nodes[n].prev].next = nodes[n].next;
16.1180 + if(_nodes[n].prev != -1) {
16.1181 + _nodes[_nodes[n].prev].next = _nodes[n].next;
16.1182 } else {
16.1183 - first_node = nodes[n].next;
16.1184 + first_node = _nodes[n].next;
16.1185 }
16.1186
16.1187 - if (nodes[n].partition_next != -1) {
16.1188 - nodes[nodes[n].partition_next].partition_prev = nodes[n].partition_prev;
16.1189 + if (_nodes[n].partition_next != -1) {
16.1190 + _nodes[_nodes[n].partition_next].partition_prev = _nodes[n].partition_prev;
16.1191 }
16.1192
16.1193 - if (nodes[n].partition_prev != -1) {
16.1194 - nodes[nodes[n].partition_prev].partition_next = nodes[n].partition_next;
16.1195 + if (_nodes[n].partition_prev != -1) {
16.1196 + _nodes[_nodes[n].partition_prev].partition_next = _nodes[n].partition_next;
16.1197 } else {
16.1198 - if (nodes[n].red) {
16.1199 - first_red = nodes[n].partition_next;
16.1200 + if (_nodes[n].red) {
16.1201 + first_red = _nodes[n].partition_next;
16.1202 } else {
16.1203 - first_blue = nodes[n].partition_next;
16.1204 + first_blue = _nodes[n].partition_next;
16.1205 }
16.1206 }
16.1207
16.1208 - if (nodes[n].red) {
16.1209 - nodes[n].next = first_free_red;
16.1210 + if (_nodes[n].red) {
16.1211 + _nodes[n].next = first_free_red;
16.1212 first_free_red = n;
16.1213 } else {
16.1214 - nodes[n].next = first_free_blue;
16.1215 + _nodes[n].next = first_free_blue;
16.1216 first_free_blue = n;
16.1217 }
16.1218 - nodes[n].prev = -2;
16.1219 + _nodes[n].prev = -2;
16.1220 }
16.1221
16.1222 void erase(const Edge& edge) {
16.1223 int n = edge.id * 2;
16.1224
16.1225 - if (arcs[n].next_out != -1) {
16.1226 - arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
16.1227 + if (_arcs[n].next_out != -1) {
16.1228 + _arcs[_arcs[n].next_out].prev_out = _arcs[n].prev_out;
16.1229 }
16.1230
16.1231 - if (arcs[n].prev_out != -1) {
16.1232 - arcs[arcs[n].prev_out].next_out = arcs[n].next_out;
16.1233 + if (_arcs[n].prev_out != -1) {
16.1234 + _arcs[_arcs[n].prev_out].next_out = _arcs[n].next_out;
16.1235 } else {
16.1236 - nodes[arcs[n | 1].target].first_out = arcs[n].next_out;
16.1237 + _nodes[_arcs[n | 1].target].first_out = _arcs[n].next_out;
16.1238 }
16.1239
16.1240 - if (arcs[n | 1].next_out != -1) {
16.1241 - arcs[arcs[n | 1].next_out].prev_out = arcs[n | 1].prev_out;
16.1242 + if (_arcs[n | 1].next_out != -1) {
16.1243 + _arcs[_arcs[n | 1].next_out].prev_out = _arcs[n | 1].prev_out;
16.1244 }
16.1245
16.1246 - if (arcs[n | 1].prev_out != -1) {
16.1247 - arcs[arcs[n | 1].prev_out].next_out = arcs[n | 1].next_out;
16.1248 + if (_arcs[n | 1].prev_out != -1) {
16.1249 + _arcs[_arcs[n | 1].prev_out].next_out = _arcs[n | 1].next_out;
16.1250 } else {
16.1251 - nodes[arcs[n].target].first_out = arcs[n | 1].next_out;
16.1252 + _nodes[_arcs[n].target].first_out = _arcs[n | 1].next_out;
16.1253 }
16.1254
16.1255 - arcs[n].next_out = first_free_arc;
16.1256 + _arcs[n].next_out = first_free_arc;
16.1257 first_free_arc = n;
16.1258 - arcs[n].prev_out = -2;
16.1259 - arcs[n | 1].prev_out = -2;
16.1260 + _arcs[n].prev_out = -2;
16.1261 + _arcs[n | 1].prev_out = -2;
16.1262
16.1263 }
16.1264
16.1265 void clear() {
16.1266 - arcs.clear();
16.1267 - nodes.clear();
16.1268 + _arcs.clear();
16.1269 + _nodes.clear();
16.1270 first_node = first_free_arc = first_red = first_blue =
16.1271 max_red = max_blue = first_free_red = first_free_blue = -1;
16.1272 }
16.1273 @@ -2055,46 +2055,46 @@
16.1274 protected:
16.1275
16.1276 void changeRed(Edge e, RedNode n) {
16.1277 - if(arcs[(2 * e.id) | 1].next_out != -1) {
16.1278 - arcs[arcs[(2 * e.id) | 1].next_out].prev_out =
16.1279 - arcs[(2 * e.id) | 1].prev_out;
16.1280 + if(_arcs[(2 * e.id) | 1].next_out != -1) {
16.1281 + _arcs[_arcs[(2 * e.id) | 1].next_out].prev_out =
16.1282 + _arcs[(2 * e.id) | 1].prev_out;
16.1283 }
16.1284 - if(arcs[(2 * e.id) | 1].prev_out != -1) {
16.1285 - arcs[arcs[(2 * e.id) | 1].prev_out].next_out =
16.1286 - arcs[(2 * e.id) | 1].next_out;
16.1287 + if(_arcs[(2 * e.id) | 1].prev_out != -1) {
16.1288 + _arcs[_arcs[(2 * e.id) | 1].prev_out].next_out =
16.1289 + _arcs[(2 * e.id) | 1].next_out;
16.1290 } else {
16.1291 - nodes[arcs[2 * e.id].target].first_out =
16.1292 - arcs[(2 * e.id) | 1].next_out;
16.1293 + _nodes[_arcs[2 * e.id].target].first_out =
16.1294 + _arcs[(2 * e.id) | 1].next_out;
16.1295 }
16.1296
16.1297 - if (nodes[n.id].first_out != -1) {
16.1298 - arcs[nodes[n.id].first_out].prev_out = ((2 * e.id) | 1);
16.1299 + if (_nodes[n.id].first_out != -1) {
16.1300 + _arcs[_nodes[n.id].first_out].prev_out = ((2 * e.id) | 1);
16.1301 }
16.1302 - arcs[2 * e.id].target = n.id;
16.1303 - arcs[(2 * e.id) | 1].prev_out = -1;
16.1304 - arcs[(2 * e.id) | 1].next_out = nodes[n.id].first_out;
16.1305 - nodes[n.id].first_out = ((2 * e.id) | 1);
16.1306 + _arcs[2 * e.id].target = n.id;
16.1307 + _arcs[(2 * e.id) | 1].prev_out = -1;
16.1308 + _arcs[(2 * e.id) | 1].next_out = _nodes[n.id].first_out;
16.1309 + _nodes[n.id].first_out = ((2 * e.id) | 1);
16.1310 }
16.1311
16.1312 void changeBlue(Edge e, BlueNode n) {
16.1313 - if(arcs[2 * e.id].next_out != -1) {
16.1314 - arcs[arcs[2 * e.id].next_out].prev_out = arcs[2 * e.id].prev_out;
16.1315 + if(_arcs[2 * e.id].next_out != -1) {
16.1316 + _arcs[_arcs[2 * e.id].next_out].prev_out = _arcs[2 * e.id].prev_out;
16.1317 }
16.1318 - if(arcs[2 * e.id].prev_out != -1) {
16.1319 - arcs[arcs[2 * e.id].prev_out].next_out =
16.1320 - arcs[2 * e.id].next_out;
16.1321 + if(_arcs[2 * e.id].prev_out != -1) {
16.1322 + _arcs[_arcs[2 * e.id].prev_out].next_out =
16.1323 + _arcs[2 * e.id].next_out;
16.1324 } else {
16.1325 - nodes[arcs[(2 * e.id) | 1].target].first_out =
16.1326 - arcs[2 * e.id].next_out;
16.1327 + _nodes[_arcs[(2 * e.id) | 1].target].first_out =
16.1328 + _arcs[2 * e.id].next_out;
16.1329 }
16.1330
16.1331 - if (nodes[n.id].first_out != -1) {
16.1332 - arcs[nodes[n.id].first_out].prev_out = 2 * e.id;
16.1333 + if (_nodes[n.id].first_out != -1) {
16.1334 + _arcs[_nodes[n.id].first_out].prev_out = 2 * e.id;
16.1335 }
16.1336 - arcs[(2 * e.id) | 1].target = n.id;
16.1337 - arcs[2 * e.id].prev_out = -1;
16.1338 - arcs[2 * e.id].next_out = nodes[n.id].first_out;
16.1339 - nodes[n.id].first_out = 2 * e.id;
16.1340 + _arcs[(2 * e.id) | 1].target = n.id;
16.1341 + _arcs[2 * e.id].prev_out = -1;
16.1342 + _arcs[2 * e.id].next_out = _nodes[n.id].first_out;
16.1343 + _nodes[n.id].first_out = 2 * e.id;
16.1344 }
16.1345
16.1346 };
16.1347 @@ -2249,7 +2249,7 @@
16.1348 /// then it is worth reserving space for this amount before starting
16.1349 /// to build the graph.
16.1350 /// \sa reserveEdge()
16.1351 - void reserveNode(int n) { nodes.reserve(n); };
16.1352 + void reserveNode(int n) { _nodes.reserve(n); };
16.1353
16.1354 /// Reserve memory for edges.
16.1355
16.1356 @@ -2259,7 +2259,7 @@
16.1357 /// then it is worth reserving space for this amount before starting
16.1358 /// to build the graph.
16.1359 /// \sa reserveNode()
16.1360 - void reserveEdge(int m) { arcs.reserve(2 * m); };
16.1361 + void reserveEdge(int m) { _arcs.reserve(2 * m); };
16.1362
16.1363 /// \brief Class to make a snapshot of the graph and restore
16.1364 /// it later.
17.1 --- a/lemon/lp_base.h Thu Apr 02 22:34:03 2015 +0200
17.2 +++ b/lemon/lp_base.h Sun Jan 05 22:24:56 2014 +0100
17.3 @@ -31,6 +31,8 @@
17.4 #include<lemon/core.h>
17.5 #include<lemon/bits/solver_bits.h>
17.6
17.7 +#include<lemon/bits/stl_iterators.h>
17.8 +
17.9 ///\file
17.10 ///\brief The interface of the LP solver interface.
17.11 ///\ingroup lp_group
17.12 @@ -45,8 +47,8 @@
17.13
17.14 protected:
17.15
17.16 - _solver_bits::VarIndex rows;
17.17 - _solver_bits::VarIndex cols;
17.18 + _solver_bits::VarIndex _rows;
17.19 + _solver_bits::VarIndex _cols;
17.20
17.21 public:
17.22
17.23 @@ -166,7 +168,7 @@
17.24 ///
17.25 ColIt(const LpBase &solver) : _solver(&solver)
17.26 {
17.27 - _solver->cols.firstItem(_id);
17.28 + _solver->_cols.firstItem(_id);
17.29 }
17.30 /// Invalid constructor \& conversion
17.31
17.32 @@ -179,11 +181,26 @@
17.33 ///
17.34 ColIt &operator++()
17.35 {
17.36 - _solver->cols.nextItem(_id);
17.37 + _solver->_cols.nextItem(_id);
17.38 return *this;
17.39 }
17.40 };
17.41
17.42 + /// \brief Gets the collection of the columns of the LP problem.
17.43 + ///
17.44 + /// This function can be used for iterating on
17.45 + /// the columns of the LP problem. It returns a wrapped ColIt, which looks
17.46 + /// like an STL container (by having begin() and end())
17.47 + /// which you can use in range-based for loops, STL algorithms, etc.
17.48 + /// For example you can write:
17.49 + ///\code
17.50 + /// for(auto c: lp.cols())
17.51 + /// doSomething(c);
17.52 + LemonRangeWrapper1<ColIt, LpBase> cols() {
17.53 + return LemonRangeWrapper1<ColIt, LpBase>(*this);
17.54 + }
17.55 +
17.56 +
17.57 /// \brief Returns the ID of the column.
17.58 static int id(const Col& col) { return col._id; }
17.59 /// \brief Returns the column with the given ID.
17.60 @@ -261,7 +278,7 @@
17.61 ///
17.62 RowIt(const LpBase &solver) : _solver(&solver)
17.63 {
17.64 - _solver->rows.firstItem(_id);
17.65 + _solver->_rows.firstItem(_id);
17.66 }
17.67 /// Invalid constructor \& conversion
17.68
17.69 @@ -274,10 +291,25 @@
17.70 ///
17.71 RowIt &operator++()
17.72 {
17.73 - _solver->rows.nextItem(_id);
17.74 + _solver->_rows.nextItem(_id);
17.75 return *this;
17.76 }
17.77 };
17.78 +
17.79 + /// \brief Gets the collection of the rows of the LP problem.
17.80 + ///
17.81 + /// This function can be used for iterating on
17.82 + /// the rows of the LP problem. It returns a wrapped RowIt, which looks
17.83 + /// like an STL container (by having begin() and end())
17.84 + /// which you can use in range-based for loops, STL algorithms, etc.
17.85 + /// For example you can write:
17.86 + ///\code
17.87 + /// for(auto c: lp.rows())
17.88 + /// doSomething(c);
17.89 + LemonRangeWrapper1<RowIt, LpBase> rows() {
17.90 + return LemonRangeWrapper1<RowIt, LpBase>(*this);
17.91 + }
17.92 +
17.93
17.94 /// \brief Returns the ID of the row.
17.95 static int id(const Row& row) { return row._id; }
17.96 @@ -934,11 +966,11 @@
17.97
17.98 //Abstract virtual functions
17.99
17.100 - virtual int _addColId(int col) { return cols.addIndex(col); }
17.101 - virtual int _addRowId(int row) { return rows.addIndex(row); }
17.102 + virtual int _addColId(int col) { return _cols.addIndex(col); }
17.103 + virtual int _addRowId(int row) { return _rows.addIndex(row); }
17.104
17.105 - virtual void _eraseColId(int col) { cols.eraseIndex(col); }
17.106 - virtual void _eraseRowId(int row) { rows.eraseIndex(row); }
17.107 + virtual void _eraseColId(int col) { _cols.eraseIndex(col); }
17.108 + virtual void _eraseRowId(int row) { _rows.eraseIndex(row); }
17.109
17.110 virtual int _addCol() = 0;
17.111 virtual int _addRow() = 0;
17.112 @@ -1003,7 +1035,7 @@
17.113 //Constant component of the objective function
17.114 Value obj_const_comp;
17.115
17.116 - LpBase() : rows(), cols(), obj_const_comp(0) {}
17.117 + LpBase() : _rows(), _cols(), obj_const_comp(0) {}
17.118
17.119 public:
17.120
17.121 @@ -1115,8 +1147,8 @@
17.122 ///a better one.
17.123 void col(Col c, const DualExpr &e) {
17.124 e.simplify();
17.125 - _setColCoeffs(cols(id(c)), ExprIterator(e.comps.begin(), rows),
17.126 - ExprIterator(e.comps.end(), rows));
17.127 + _setColCoeffs(_cols(id(c)), ExprIterator(e.comps.begin(), _rows),
17.128 + ExprIterator(e.comps.end(), _rows));
17.129 }
17.130
17.131 ///Get a column (i.e a dual constraint) of the LP
17.132 @@ -1125,7 +1157,7 @@
17.133 ///\return the dual expression associated to the column
17.134 DualExpr col(Col c) const {
17.135 DualExpr e;
17.136 - _getColCoeffs(cols(id(c)), InsertIterator(e.comps, rows));
17.137 + _getColCoeffs(_cols(id(c)), InsertIterator(e.comps, _rows));
17.138 return e;
17.139 }
17.140
17.141 @@ -1212,10 +1244,10 @@
17.142 ///\param u is the upper bound (\ref INF means no bound)
17.143 void row(Row r, Value l, const Expr &e, Value u) {
17.144 e.simplify();
17.145 - _setRowCoeffs(rows(id(r)), ExprIterator(e.comps.begin(), cols),
17.146 - ExprIterator(e.comps.end(), cols));
17.147 - _setRowLowerBound(rows(id(r)),l - *e);
17.148 - _setRowUpperBound(rows(id(r)),u - *e);
17.149 + _setRowCoeffs(_rows(id(r)), ExprIterator(e.comps.begin(), _cols),
17.150 + ExprIterator(e.comps.end(), _cols));
17.151 + _setRowLowerBound(_rows(id(r)),l - *e);
17.152 + _setRowUpperBound(_rows(id(r)),u - *e);
17.153 }
17.154
17.155 ///Set a row (i.e a constraint) of the LP
17.156 @@ -1234,7 +1266,7 @@
17.157 ///\return the expression associated to the row
17.158 Expr row(Row r) const {
17.159 Expr e;
17.160 - _getRowCoeffs(rows(id(r)), InsertIterator(e.comps, cols));
17.161 + _getRowCoeffs(_rows(id(r)), InsertIterator(e.comps, _cols));
17.162 return e;
17.163 }
17.164
17.165 @@ -1247,8 +1279,8 @@
17.166 Row addRow(Value l,const Expr &e, Value u) {
17.167 Row r;
17.168 e.simplify();
17.169 - r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), cols),
17.170 - ExprIterator(e.comps.end(), cols), u - *e));
17.171 + r._id = _addRowId(_addRow(l - *e, ExprIterator(e.comps.begin(), _cols),
17.172 + ExprIterator(e.comps.end(), _cols), u - *e));
17.173 return r;
17.174 }
17.175
17.176 @@ -1260,8 +1292,8 @@
17.177 Row r;
17.178 c.expr().simplify();
17.179 r._id = _addRowId(_addRow(c.lowerBounded()?c.lowerBound()-*c.expr():-INF,
17.180 - ExprIterator(c.expr().comps.begin(), cols),
17.181 - ExprIterator(c.expr().comps.end(), cols),
17.182 + ExprIterator(c.expr().comps.begin(), _cols),
17.183 + ExprIterator(c.expr().comps.end(), _cols),
17.184 c.upperBounded()?c.upperBound()-*c.expr():INF));
17.185 return r;
17.186 }
17.187 @@ -1269,15 +1301,15 @@
17.188
17.189 ///\param c is the column to be deleted
17.190 void erase(Col c) {
17.191 - _eraseCol(cols(id(c)));
17.192 - _eraseColId(cols(id(c)));
17.193 + _eraseCol(_cols(id(c)));
17.194 + _eraseColId(_cols(id(c)));
17.195 }
17.196 ///Erase a row (i.e a constraint) from the LP
17.197
17.198 ///\param r is the row to be deleted
17.199 void erase(Row r) {
17.200 - _eraseRow(rows(id(r)));
17.201 - _eraseRowId(rows(id(r)));
17.202 + _eraseRow(_rows(id(r)));
17.203 + _eraseRowId(_rows(id(r)));
17.204 }
17.205
17.206 /// Get the name of a column
17.207 @@ -1286,7 +1318,7 @@
17.208 ///\return The name of the colunm
17.209 std::string colName(Col c) const {
17.210 std::string name;
17.211 - _getColName(cols(id(c)), name);
17.212 + _getColName(_cols(id(c)), name);
17.213 return name;
17.214 }
17.215
17.216 @@ -1295,7 +1327,7 @@
17.217 ///\param c is the coresponding column
17.218 ///\param name The name to be given
17.219 void colName(Col c, const std::string& name) {
17.220 - _setColName(cols(id(c)), name);
17.221 + _setColName(_cols(id(c)), name);
17.222 }
17.223
17.224 /// Get the column by its name
17.225 @@ -1304,7 +1336,7 @@
17.226 ///\return the proper column or \c INVALID
17.227 Col colByName(const std::string& name) const {
17.228 int k = _colByName(name);
17.229 - return k != -1 ? Col(cols[k]) : Col(INVALID);
17.230 + return k != -1 ? Col(_cols[k]) : Col(INVALID);
17.231 }
17.232
17.233 /// Get the name of a row
17.234 @@ -1313,7 +1345,7 @@
17.235 ///\return The name of the row
17.236 std::string rowName(Row r) const {
17.237 std::string name;
17.238 - _getRowName(rows(id(r)), name);
17.239 + _getRowName(_rows(id(r)), name);
17.240 return name;
17.241 }
17.242
17.243 @@ -1322,7 +1354,7 @@
17.244 ///\param r is the coresponding row
17.245 ///\param name The name to be given
17.246 void rowName(Row r, const std::string& name) {
17.247 - _setRowName(rows(id(r)), name);
17.248 + _setRowName(_rows(id(r)), name);
17.249 }
17.250
17.251 /// Get the row by its name
17.252 @@ -1331,7 +1363,7 @@
17.253 ///\return the proper row or \c INVALID
17.254 Row rowByName(const std::string& name) const {
17.255 int k = _rowByName(name);
17.256 - return k != -1 ? Row(rows[k]) : Row(INVALID);
17.257 + return k != -1 ? Row(_rows[k]) : Row(INVALID);
17.258 }
17.259
17.260 /// Set an element of the coefficient matrix of the LP
17.261 @@ -1340,7 +1372,7 @@
17.262 ///\param c is the column of the element to be modified
17.263 ///\param val is the new value of the coefficient
17.264 void coeff(Row r, Col c, Value val) {
17.265 - _setCoeff(rows(id(r)),cols(id(c)), val);
17.266 + _setCoeff(_rows(id(r)),_cols(id(c)), val);
17.267 }
17.268
17.269 /// Get an element of the coefficient matrix of the LP
17.270 @@ -1349,7 +1381,7 @@
17.271 ///\param c is the column of the element
17.272 ///\return the corresponding coefficient
17.273 Value coeff(Row r, Col c) const {
17.274 - return _getCoeff(rows(id(r)),cols(id(c)));
17.275 + return _getCoeff(_rows(id(r)),_cols(id(c)));
17.276 }
17.277
17.278 /// Set the lower bound of a column (i.e a variable)
17.279 @@ -1358,7 +1390,7 @@
17.280 /// extended number of type Value, i.e. a finite number of type
17.281 /// Value or -\ref INF.
17.282 void colLowerBound(Col c, Value value) {
17.283 - _setColLowerBound(cols(id(c)),value);
17.284 + _setColLowerBound(_cols(id(c)),value);
17.285 }
17.286
17.287 /// Get the lower bound of a column (i.e a variable)
17.288 @@ -1367,7 +1399,7 @@
17.289 /// (this might be -\ref INF as well).
17.290 ///\return The lower bound for column \c c
17.291 Value colLowerBound(Col c) const {
17.292 - return _getColLowerBound(cols(id(c)));
17.293 + return _getColLowerBound(_cols(id(c)));
17.294 }
17.295
17.296 ///\brief Set the lower bound of several columns
17.297 @@ -1413,7 +1445,7 @@
17.298 /// extended number of type Value, i.e. a finite number of type
17.299 /// Value or \ref INF.
17.300 void colUpperBound(Col c, Value value) {
17.301 - _setColUpperBound(cols(id(c)),value);
17.302 + _setColUpperBound(_cols(id(c)),value);
17.303 };
17.304
17.305 /// Get the upper bound of a column (i.e a variable)
17.306 @@ -1422,7 +1454,7 @@
17.307 /// (this might be \ref INF as well).
17.308 /// \return The upper bound for column \c c
17.309 Value colUpperBound(Col c) const {
17.310 - return _getColUpperBound(cols(id(c)));
17.311 + return _getColUpperBound(_cols(id(c)));
17.312 }
17.313
17.314 ///\brief Set the upper bound of several columns
17.315 @@ -1469,8 +1501,8 @@
17.316 /// extended number of type Value, i.e. a finite number of type
17.317 /// Value, -\ref INF or \ref INF.
17.318 void colBounds(Col c, Value lower, Value upper) {
17.319 - _setColLowerBound(cols(id(c)),lower);
17.320 - _setColUpperBound(cols(id(c)),upper);
17.321 + _setColLowerBound(_cols(id(c)),lower);
17.322 + _setColUpperBound(_cols(id(c)),upper);
17.323 }
17.324
17.325 ///\brief Set the lower and the upper bound of several columns
17.326 @@ -1515,7 +1547,7 @@
17.327 /// extended number of type Value, i.e. a finite number of type
17.328 /// Value or -\ref INF.
17.329 void rowLowerBound(Row r, Value value) {
17.330 - _setRowLowerBound(rows(id(r)),value);
17.331 + _setRowLowerBound(_rows(id(r)),value);
17.332 }
17.333
17.334 /// Get the lower bound of a row (i.e a constraint)
17.335 @@ -1524,7 +1556,7 @@
17.336 /// (this might be -\ref INF as well).
17.337 ///\return The lower bound for row \c r
17.338 Value rowLowerBound(Row r) const {
17.339 - return _getRowLowerBound(rows(id(r)));
17.340 + return _getRowLowerBound(_rows(id(r)));
17.341 }
17.342
17.343 /// Set the upper bound of a row (i.e a constraint)
17.344 @@ -1533,7 +1565,7 @@
17.345 /// extended number of type Value, i.e. a finite number of type
17.346 /// Value or -\ref INF.
17.347 void rowUpperBound(Row r, Value value) {
17.348 - _setRowUpperBound(rows(id(r)),value);
17.349 + _setRowUpperBound(_rows(id(r)),value);
17.350 }
17.351
17.352 /// Get the upper bound of a row (i.e a constraint)
17.353 @@ -1542,22 +1574,22 @@
17.354 /// (this might be -\ref INF as well).
17.355 ///\return The upper bound for row \c r
17.356 Value rowUpperBound(Row r) const {
17.357 - return _getRowUpperBound(rows(id(r)));
17.358 + return _getRowUpperBound(_rows(id(r)));
17.359 }
17.360
17.361 ///Set an element of the objective function
17.362 - void objCoeff(Col c, Value v) {_setObjCoeff(cols(id(c)),v); };
17.363 + void objCoeff(Col c, Value v) {_setObjCoeff(_cols(id(c)),v); };
17.364
17.365 ///Get an element of the objective function
17.366 - Value objCoeff(Col c) const { return _getObjCoeff(cols(id(c))); };
17.367 + Value objCoeff(Col c) const { return _getObjCoeff(_cols(id(c))); };
17.368
17.369 ///Set the objective function
17.370
17.371 ///\param e is a linear expression of type \ref Expr.
17.372 ///
17.373 void obj(const Expr& e) {
17.374 - _setObjCoeffs(ExprIterator(e.comps.begin(), cols),
17.375 - ExprIterator(e.comps.end(), cols));
17.376 + _setObjCoeffs(ExprIterator(e.comps.begin(), _cols),
17.377 + ExprIterator(e.comps.end(), _cols));
17.378 obj_const_comp = *e;
17.379 }
17.380
17.381 @@ -1567,7 +1599,7 @@
17.382 ///Expr.
17.383 Expr obj() const {
17.384 Expr e;
17.385 - _getObjCoeffs(InsertIterator(e.comps, cols));
17.386 + _getObjCoeffs(InsertIterator(e.comps, _cols));
17.387 *e = obj_const_comp;
17.388 return e;
17.389 }
17.390 @@ -1586,7 +1618,7 @@
17.391 void min() { _setSense(MIN); }
17.392
17.393 ///Clear the problem
17.394 - void clear() { _clear(); rows.clear(); cols.clear(); }
17.395 + void clear() { _clear(); _rows.clear(); _cols.clear(); }
17.396
17.397 /// Set the message level of the solver
17.398 void messageLevel(MessageLevel level) { _messageLevel(level); }
17.399 @@ -1929,7 +1961,7 @@
17.400
17.401 /// Return the primal value of the column.
17.402 /// \pre The problem is solved.
17.403 - Value primal(Col c) const { return _getPrimal(cols(id(c))); }
17.404 + Value primal(Col c) const { return _getPrimal(_cols(id(c))); }
17.405
17.406 /// Return the primal value of the expression
17.407
17.408 @@ -1956,13 +1988,13 @@
17.409 /// \pre The problem is solved and the dual problem is infeasible.
17.410 /// \note Some solvers does not provide primal ray calculation
17.411 /// functions.
17.412 - Value primalRay(Col c) const { return _getPrimalRay(cols(id(c))); }
17.413 + Value primalRay(Col c) const { return _getPrimalRay(_cols(id(c))); }
17.414
17.415 /// Return the dual value of the row
17.416
17.417 /// Return the dual value of the row.
17.418 /// \pre The problem is solved.
17.419 - Value dual(Row r) const { return _getDual(rows(id(r))); }
17.420 + Value dual(Row r) const { return _getDual(_rows(id(r))); }
17.421
17.422 /// Return the dual value of the dual expression
17.423
17.424 @@ -1990,17 +2022,17 @@
17.425 /// \pre The problem is solved and the primal problem is infeasible.
17.426 /// \note Some solvers does not provide dual ray calculation
17.427 /// functions.
17.428 - Value dualRay(Row r) const { return _getDualRay(rows(id(r))); }
17.429 + Value dualRay(Row r) const { return _getDualRay(_rows(id(r))); }
17.430
17.431 /// Return the basis status of the column
17.432
17.433 /// \see VarStatus
17.434 - VarStatus colStatus(Col c) const { return _getColStatus(cols(id(c))); }
17.435 + VarStatus colStatus(Col c) const { return _getColStatus(_cols(id(c))); }
17.436
17.437 /// Return the basis status of the row
17.438
17.439 /// \see VarStatus
17.440 - VarStatus rowStatus(Row r) const { return _getRowStatus(rows(id(r))); }
17.441 + VarStatus rowStatus(Row r) const { return _getRowStatus(_rows(id(r))); }
17.442
17.443 ///The value of the objective function
17.444
17.445 @@ -2080,7 +2112,7 @@
17.446 ///Sets the type of the given column to the given type.
17.447 ///
17.448 void colType(Col c, ColTypes col_type) {
17.449 - _setColType(cols(id(c)),col_type);
17.450 + _setColType(_cols(id(c)),col_type);
17.451 }
17.452
17.453 ///Gives back the type of the column.
17.454 @@ -2088,7 +2120,7 @@
17.455 ///Gives back the type of the column.
17.456 ///
17.457 ColTypes colType(Col c) const {
17.458 - return _getColType(cols(id(c)));
17.459 + return _getColType(_cols(id(c)));
17.460 }
17.461 ///@}
17.462
17.463 @@ -2105,7 +2137,7 @@
17.464
17.465 /// Return the value of the row in the solution.
17.466 /// \pre The problem is solved.
17.467 - Value sol(Col c) const { return _getSol(cols(id(c))); }
17.468 + Value sol(Col c) const { return _getSol(_cols(id(c))); }
17.469
17.470 /// Return the value of the expression in the solution
17.471
18.1 --- a/lemon/maps.h Thu Apr 02 22:34:03 2015 +0200
18.2 +++ b/lemon/maps.h Sun Jan 05 22:24:56 2014 +0100
18.3 @@ -25,6 +25,7 @@
18.4 #include <map>
18.5
18.6 #include <lemon/core.h>
18.7 +#include <lemon/bits/stl_iterators.h>
18.8
18.9 ///\file
18.10 ///\ingroup maps
18.11 @@ -2581,6 +2582,16 @@
18.12 const IterableBoolMap* _map;
18.13 };
18.14
18.15 + /// \brief STL style iterator for the keys mapped to \c true.
18.16 + ///
18.17 + /// This is an STL style wrapper for \ref TrueIt.
18.18 + /// It can be used in range-based for loops, STL algorithms, etc.
18.19 + LemonRangeWrapper1<TrueIt, IterableBoolMap>
18.20 + trueKeys() {
18.21 + return LemonRangeWrapper1<TrueIt, IterableBoolMap>(*this);
18.22 + }
18.23 +
18.24 +
18.25 /// \brief Iterator for the keys mapped to \c false.
18.26 ///
18.27 /// Iterator for the keys mapped to \c false. It works
18.28 @@ -2620,6 +2631,16 @@
18.29 const IterableBoolMap* _map;
18.30 };
18.31
18.32 + /// \brief STL style iterator for the keys mapped to \c false.
18.33 + ///
18.34 + /// This is an STL style wrapper for \ref FalseIt.
18.35 + /// It can be used in range-based for loops, STL algorithms, etc.
18.36 + LemonRangeWrapper1<FalseIt, IterableBoolMap>
18.37 + falseKeys() {
18.38 + return LemonRangeWrapper1<FalseIt, IterableBoolMap>(*this);
18.39 + }
18.40 +
18.41 +
18.42 /// \brief Iterator for the keys mapped to a given value.
18.43 ///
18.44 /// Iterator for the keys mapped to a given value. It works
18.45 @@ -2664,6 +2685,15 @@
18.46 const IterableBoolMap* _map;
18.47 };
18.48
18.49 + /// \brief STL style iterator for the keys mapped to a given value.
18.50 + ///
18.51 + /// This is an STL style wrapper for \ref ItemIt.
18.52 + /// It can be used in range-based for loops, STL algorithms, etc.
18.53 + LemonRangeWrapper2<ItemIt, IterableBoolMap, bool>
18.54 + items(bool value) {
18.55 + return LemonRangeWrapper2<ItemIt, IterableBoolMap, bool>(*this, value);
18.56 + }
18.57 +
18.58 protected:
18.59
18.60 virtual void add(const Key& key) {
18.61 @@ -3005,6 +3035,16 @@
18.62 const IterableIntMap* _map;
18.63 };
18.64
18.65 + /// \brief STL style iterator for the keys with the same value.
18.66 + ///
18.67 + /// This is an STL style wrapper for \ref ItemIt.
18.68 + /// It can be used in range-based for loops, STL algorithms, etc.
18.69 + LemonRangeWrapper2<ItemIt, IterableIntMap, int>
18.70 + items(int value) {
18.71 + return LemonRangeWrapper2<ItemIt, IterableIntMap, int>(*this, value);
18.72 + }
18.73 +
18.74 +
18.75 protected:
18.76
18.77 virtual void erase(const Key& key) {
18.78 @@ -3248,6 +3288,16 @@
18.79 const IterableValueMap* _map;
18.80 };
18.81
18.82 + /// \brief STL style iterator for the keys with the same value.
18.83 + ///
18.84 + /// This is an STL style wrapper for \ref ItemIt.
18.85 + /// It can be used in range-based for loops, STL algorithms, etc.
18.86 + LemonRangeWrapper2<ItemIt, IterableValueMap, V>
18.87 + items(const V& value) {
18.88 + return LemonRangeWrapper2<ItemIt, IterableValueMap, V>(*this, value);
18.89 + }
18.90 +
18.91 +
18.92 protected:
18.93
18.94 virtual void add(const Key& key) {
19.1 --- a/lemon/path.h Thu Apr 02 22:34:03 2015 +0200
19.2 +++ b/lemon/path.h Sun Jan 05 22:24:56 2014 +0100
19.3 @@ -30,6 +30,7 @@
19.4 #include <lemon/error.h>
19.5 #include <lemon/core.h>
19.6 #include <lemon/concepts/path.h>
19.7 +#include <lemon/bits/stl_iterators.h>
19.8
19.9 namespace lemon {
19.10
19.11 @@ -140,6 +141,23 @@
19.12 int idx;
19.13 };
19.14
19.15 + /// \brief Gets the collection of the arcs of the path.
19.16 + ///
19.17 + /// This function can be used for iterating on the
19.18 + /// arcs of the path. It returns a wrapped
19.19 + /// ArcIt, which looks like an STL container
19.20 + /// (by having begin() and end()) which you can use in range-based
19.21 + /// for loops, STL algorithms, etc.
19.22 + /// For example you can write:
19.23 + ///\code
19.24 + /// for(auto a: p.arcs())
19.25 + /// doSomething(a);
19.26 + ///\endcode
19.27 + LemonRangeWrapper1<ArcIt, Path> arcs() const {
19.28 + return LemonRangeWrapper1<ArcIt, Path>(*this);
19.29 + }
19.30 +
19.31 +
19.32 /// \brief Length of the path.
19.33 int length() const { return head.size() + tail.size(); }
19.34 /// \brief Return whether the path is empty.
19.35 @@ -345,6 +363,23 @@
19.36 int idx;
19.37 };
19.38
19.39 + /// \brief Gets the collection of the arcs of the path.
19.40 + ///
19.41 + /// This function can be used for iterating on the
19.42 + /// arcs of the path. It returns a wrapped
19.43 + /// ArcIt, which looks like an STL container
19.44 + /// (by having begin() and end()) which you can use in range-based
19.45 + /// for loops, STL algorithms, etc.
19.46 + /// For example you can write:
19.47 + ///\code
19.48 + /// for(auto a: p.arcs())
19.49 + /// doSomething(a);
19.50 + ///\endcode
19.51 + LemonRangeWrapper1<ArcIt, SimplePath> arcs() const {
19.52 + return LemonRangeWrapper1<ArcIt, SimplePath>(*this);
19.53 + }
19.54 +
19.55 +
19.56 /// \brief Length of the path.
19.57 int length() const { return data.size(); }
19.58 /// \brief Return true if the path is empty.
19.59 @@ -543,6 +578,23 @@
19.60 Node *node;
19.61 };
19.62
19.63 + /// \brief Gets the collection of the arcs of the path.
19.64 + ///
19.65 + /// This function can be used for iterating on the
19.66 + /// arcs of the path. It returns a wrapped
19.67 + /// ArcIt, which looks like an STL container
19.68 + /// (by having begin() and end()) which you can use in range-based
19.69 + /// for loops, STL algorithms, etc.
19.70 + /// For example you can write:
19.71 + ///\code
19.72 + /// for(auto a: p.arcs())
19.73 + /// doSomething(a);
19.74 + ///\endcode
19.75 + LemonRangeWrapper1<ArcIt, ListPath> arcs() const {
19.76 + return LemonRangeWrapper1<ArcIt, ListPath>(*this);
19.77 + }
19.78 +
19.79 +
19.80 /// \brief The n-th arc.
19.81 ///
19.82 /// This function looks for the n-th arc in O(n) time.
19.83 @@ -795,11 +847,11 @@
19.84 /// \brief Default constructor
19.85 ///
19.86 /// Default constructor
19.87 - StaticPath() : len(0), arcs(0) {}
19.88 + StaticPath() : len(0), _arcs(0) {}
19.89
19.90 /// \brief Copy constructor
19.91 ///
19.92 - StaticPath(const StaticPath& cpath) : arcs(0) {
19.93 + StaticPath(const StaticPath& cpath) : _arcs(0) {
19.94 pathCopy(cpath, *this);
19.95 }
19.96
19.97 @@ -807,7 +859,7 @@
19.98 ///
19.99 /// This path can be initialized from any other path type.
19.100 template <typename CPath>
19.101 - StaticPath(const CPath& cpath) : arcs(0) {
19.102 + StaticPath(const CPath& cpath) : _arcs(0) {
19.103 pathCopy(cpath, *this);
19.104 }
19.105
19.106 @@ -815,7 +867,7 @@
19.107 ///
19.108 /// Destructor of the path
19.109 ~StaticPath() {
19.110 - if (arcs) delete[] arcs;
19.111 + if (_arcs) delete[] _arcs;
19.112 }
19.113
19.114 /// \brief Copy assignment
19.115 @@ -882,12 +934,29 @@
19.116 const StaticPath *path;
19.117 int idx;
19.118 };
19.119 +
19.120 + /// \brief Gets the collection of the arcs of the path.
19.121 + ///
19.122 + /// This function can be used for iterating on the
19.123 + /// arcs of the path. It returns a wrapped
19.124 + /// ArcIt, which looks like an STL container
19.125 + /// (by having begin() and end()) which you can use in range-based
19.126 + /// for loops, STL algorithms, etc.
19.127 + /// For example you can write:
19.128 + ///\code
19.129 + /// for(auto a: p.arcs())
19.130 + /// doSomething(a);
19.131 + ///\endcode
19.132 + LemonRangeWrapper1<ArcIt, StaticPath> arcs() const {
19.133 + return LemonRangeWrapper1<ArcIt, StaticPath>(*this);
19.134 + }
19.135 +
19.136
19.137 /// \brief The n-th arc.
19.138 ///
19.139 /// \pre \c n is in the <tt>[0..length() - 1]</tt> range.
19.140 const Arc& nth(int n) const {
19.141 - return arcs[n];
19.142 + return _arcs[n];
19.143 }
19.144
19.145 /// \brief The arc iterator pointing to the n-th arc.
19.146 @@ -904,18 +973,18 @@
19.147 /// \brief Erase all arcs in the digraph.
19.148 void clear() {
19.149 len = 0;
19.150 - if (arcs) delete[] arcs;
19.151 - arcs = 0;
19.152 + if (_arcs) delete[] _arcs;
19.153 + _arcs = 0;
19.154 }
19.155
19.156 /// \brief The first arc of the path.
19.157 const Arc& front() const {
19.158 - return arcs[0];
19.159 + return _arcs[0];
19.160 }
19.161
19.162 /// \brief The last arc of the path.
19.163 const Arc& back() const {
19.164 - return arcs[len - 1];
19.165 + return _arcs[len - 1];
19.166 }
19.167
19.168
19.169 @@ -924,10 +993,10 @@
19.170 template <typename CPath>
19.171 void build(const CPath& path) {
19.172 len = path.length();
19.173 - arcs = new Arc[len];
19.174 + _arcs = new Arc[len];
19.175 int index = 0;
19.176 for (typename CPath::ArcIt it(path); it != INVALID; ++it) {
19.177 - arcs[index] = it;
19.178 + _arcs[index] = it;
19.179 ++index;
19.180 }
19.181 }
19.182 @@ -935,17 +1004,17 @@
19.183 template <typename CPath>
19.184 void buildRev(const CPath& path) {
19.185 len = path.length();
19.186 - arcs = new Arc[len];
19.187 + _arcs = new Arc[len];
19.188 int index = len;
19.189 for (typename CPath::RevArcIt it(path); it != INVALID; ++it) {
19.190 --index;
19.191 - arcs[index] = it;
19.192 + _arcs[index] = it;
19.193 }
19.194 }
19.195
19.196 private:
19.197 int len;
19.198 - Arc* arcs;
19.199 + Arc* _arcs;
19.200 };
19.201
19.202 ///////////////////////////////////////////////////////////////////////
19.203 @@ -1157,6 +1226,25 @@
19.204
19.205 };
19.206
19.207 + /// \brief Gets the collection of the nodes of the path.
19.208 + ///
19.209 + /// This function can be used for iterating on the
19.210 + /// nodes of the path. It returns a wrapped
19.211 + /// PathNodeIt, which looks like an STL container
19.212 + /// (by having begin() and end()) which you can use in range-based
19.213 + /// for loops, STL algorithms, etc.
19.214 + /// For example you can write:
19.215 + ///\code
19.216 + /// for(auto u: pathNodes(g,p))
19.217 + /// doSomething(u);
19.218 + ///\endcode
19.219 + template<typename Path>
19.220 + LemonRangeWrapper2<PathNodeIt<Path>, typename Path::Digraph, Path>
19.221 + pathNodes(const typename Path::Digraph &g, const Path &p) {
19.222 + return
19.223 + LemonRangeWrapper2<PathNodeIt<Path>, typename Path::Digraph, Path>(g,p);
19.224 + }
19.225 +
19.226 ///@}
19.227
19.228 } // namespace lemon
20.1 --- a/lemon/smart_graph.h Thu Apr 02 22:34:03 2015 +0200
20.2 +++ b/lemon/smart_graph.h Sun Jan 05 22:24:56 2014 +0100
20.3 @@ -47,8 +47,8 @@
20.4 ArcT() {}
20.5 };
20.6
20.7 - std::vector<NodeT> nodes;
20.8 - std::vector<ArcT> arcs;
20.9 + std::vector<NodeT> _nodes;
20.10 + std::vector<ArcT> _arcs;
20.11
20.12 public:
20.13
20.14 @@ -59,46 +59,46 @@
20.15
20.16 public:
20.17
20.18 - SmartDigraphBase() : nodes(), arcs() { }
20.19 + SmartDigraphBase() : _nodes(), _arcs() { }
20.20 SmartDigraphBase(const SmartDigraphBase &_g)
20.21 - : nodes(_g.nodes), arcs(_g.arcs) { }
20.22 + : _nodes(_g._nodes), _arcs(_g._arcs) { }
20.23
20.24 typedef True NodeNumTag;
20.25 typedef True ArcNumTag;
20.26
20.27 - int nodeNum() const { return nodes.size(); }
20.28 - int arcNum() const { return arcs.size(); }
20.29 + int nodeNum() const { return _nodes.size(); }
20.30 + int arcNum() const { return _arcs.size(); }
20.31
20.32 - int maxNodeId() const { return nodes.size()-1; }
20.33 - int maxArcId() const { return arcs.size()-1; }
20.34 + int maxNodeId() const { return _nodes.size()-1; }
20.35 + int maxArcId() const { return _arcs.size()-1; }
20.36
20.37 Node addNode() {
20.38 - int n = nodes.size();
20.39 - nodes.push_back(NodeT());
20.40 - nodes[n].first_in = -1;
20.41 - nodes[n].first_out = -1;
20.42 + int n = _nodes.size();
20.43 + _nodes.push_back(NodeT());
20.44 + _nodes[n].first_in = -1;
20.45 + _nodes[n].first_out = -1;
20.46 return Node(n);
20.47 }
20.48
20.49 Arc addArc(Node u, Node v) {
20.50 - int n = arcs.size();
20.51 - arcs.push_back(ArcT());
20.52 - arcs[n].source = u._id;
20.53 - arcs[n].target = v._id;
20.54 - arcs[n].next_out = nodes[u._id].first_out;
20.55 - arcs[n].next_in = nodes[v._id].first_in;
20.56 - nodes[u._id].first_out = nodes[v._id].first_in = n;
20.57 + int n = _arcs.size();
20.58 + _arcs.push_back(ArcT());
20.59 + _arcs[n].source = u._id;
20.60 + _arcs[n].target = v._id;
20.61 + _arcs[n].next_out = _nodes[u._id].first_out;
20.62 + _arcs[n].next_in = _nodes[v._id].first_in;
20.63 + _nodes[u._id].first_out = _nodes[v._id].first_in = n;
20.64
20.65 return Arc(n);
20.66 }
20.67
20.68 void clear() {
20.69 - arcs.clear();
20.70 - nodes.clear();
20.71 + _arcs.clear();
20.72 + _nodes.clear();
20.73 }
20.74
20.75 - Node source(Arc a) const { return Node(arcs[a._id].source); }
20.76 - Node target(Arc a) const { return Node(arcs[a._id].target); }
20.77 + Node source(Arc a) const { return Node(_arcs[a._id].source); }
20.78 + Node target(Arc a) const { return Node(_arcs[a._id].target); }
20.79
20.80 static int id(Node v) { return v._id; }
20.81 static int id(Arc a) { return a._id; }
20.82 @@ -107,10 +107,10 @@
20.83 static Arc arcFromId(int id) { return Arc(id);}
20.84
20.85 bool valid(Node n) const {
20.86 - return n._id >= 0 && n._id < static_cast<int>(nodes.size());
20.87 + return n._id >= 0 && n._id < static_cast<int>(_nodes.size());
20.88 }
20.89 bool valid(Arc a) const {
20.90 - return a._id >= 0 && a._id < static_cast<int>(arcs.size());
20.91 + return a._id >= 0 && a._id < static_cast<int>(_arcs.size());
20.92 }
20.93
20.94 class Node {
20.95 @@ -145,7 +145,7 @@
20.96 };
20.97
20.98 void first(Node& node) const {
20.99 - node._id = nodes.size() - 1;
20.100 + node._id = _nodes.size() - 1;
20.101 }
20.102
20.103 static void next(Node& node) {
20.104 @@ -153,7 +153,7 @@
20.105 }
20.106
20.107 void first(Arc& arc) const {
20.108 - arc._id = arcs.size() - 1;
20.109 + arc._id = _arcs.size() - 1;
20.110 }
20.111
20.112 static void next(Arc& arc) {
20.113 @@ -161,19 +161,19 @@
20.114 }
20.115
20.116 void firstOut(Arc& arc, const Node& node) const {
20.117 - arc._id = nodes[node._id].first_out;
20.118 + arc._id = _nodes[node._id].first_out;
20.119 }
20.120
20.121 void nextOut(Arc& arc) const {
20.122 - arc._id = arcs[arc._id].next_out;
20.123 + arc._id = _arcs[arc._id].next_out;
20.124 }
20.125
20.126 void firstIn(Arc& arc, const Node& node) const {
20.127 - arc._id = nodes[node._id].first_in;
20.128 + arc._id = _nodes[node._id].first_in;
20.129 }
20.130
20.131 void nextIn(Arc& arc) const {
20.132 - arc._id = arcs[arc._id].next_in;
20.133 + arc._id = _arcs[arc._id].next_in;
20.134 }
20.135
20.136 };
20.137 @@ -266,10 +266,10 @@
20.138 Node split(Node n, bool connect = true)
20.139 {
20.140 Node b = addNode();
20.141 - nodes[b._id].first_out=nodes[n._id].first_out;
20.142 - nodes[n._id].first_out=-1;
20.143 - for(int i=nodes[b._id].first_out; i!=-1; i=arcs[i].next_out) {
20.144 - arcs[i].source=b._id;
20.145 + _nodes[b._id].first_out=_nodes[n._id].first_out;
20.146 + _nodes[n._id].first_out=-1;
20.147 + for(int i=_nodes[b._id].first_out; i!=-1; i=_arcs[i].next_out) {
20.148 + _arcs[i].source=b._id;
20.149 }
20.150 if(connect) addArc(n,b);
20.151 return b;
20.152 @@ -291,7 +291,7 @@
20.153 /// then it is worth reserving space for this amount before starting
20.154 /// to build the digraph.
20.155 /// \sa reserveArc()
20.156 - void reserveNode(int n) { nodes.reserve(n); };
20.157 + void reserveNode(int n) { _nodes.reserve(n); };
20.158
20.159 /// Reserve memory for arcs.
20.160
20.161 @@ -301,7 +301,7 @@
20.162 /// then it is worth reserving space for this amount before starting
20.163 /// to build the digraph.
20.164 /// \sa reserveNode()
20.165 - void reserveArc(int m) { arcs.reserve(m); };
20.166 + void reserveArc(int m) { _arcs.reserve(m); };
20.167
20.168 public:
20.169
20.170 @@ -311,17 +311,17 @@
20.171
20.172 void restoreSnapshot(const Snapshot &s)
20.173 {
20.174 - while(s.arc_num<arcs.size()) {
20.175 - Arc arc = arcFromId(arcs.size()-1);
20.176 + while(s.arc_num<_arcs.size()) {
20.177 + Arc arc = arcFromId(_arcs.size()-1);
20.178 Parent::notifier(Arc()).erase(arc);
20.179 - nodes[arcs.back().source].first_out=arcs.back().next_out;
20.180 - nodes[arcs.back().target].first_in=arcs.back().next_in;
20.181 - arcs.pop_back();
20.182 + _nodes[_arcs.back().source].first_out=_arcs.back().next_out;
20.183 + _nodes[_arcs.back().target].first_in=_arcs.back().next_in;
20.184 + _arcs.pop_back();
20.185 }
20.186 - while(s.node_num<nodes.size()) {
20.187 - Node node = nodeFromId(nodes.size()-1);
20.188 + while(s.node_num<_nodes.size()) {
20.189 + Node node = nodeFromId(_nodes.size()-1);
20.190 Parent::notifier(Node()).erase(node);
20.191 - nodes.pop_back();
20.192 + _nodes.pop_back();
20.193 }
20.194 }
20.195
20.196 @@ -362,8 +362,8 @@
20.197 ///This constructor immediately makes a snapshot of the given digraph.
20.198 ///
20.199 Snapshot(SmartDigraph &gr) : _graph(&gr) {
20.200 - node_num=_graph->nodes.size();
20.201 - arc_num=_graph->arcs.size();
20.202 + node_num=_graph->_nodes.size();
20.203 + arc_num=_graph->_arcs.size();
20.204 }
20.205
20.206 ///Make a snapshot.
20.207 @@ -373,8 +373,8 @@
20.208 ///call, the previous snapshot gets lost.
20.209 void save(SmartDigraph &gr) {
20.210 _graph=&gr;
20.211 - node_num=_graph->nodes.size();
20.212 - arc_num=_graph->arcs.size();
20.213 + node_num=_graph->_nodes.size();
20.214 + arc_num=_graph->_arcs.size();
20.215 }
20.216
20.217 ///Undo the changes until a snapshot.
20.218 @@ -402,8 +402,8 @@
20.219 int next_out;
20.220 };
20.221
20.222 - std::vector<NodeT> nodes;
20.223 - std::vector<ArcT> arcs;
20.224 + std::vector<NodeT> _nodes;
20.225 + std::vector<ArcT> _arcs;
20.226
20.227 public:
20.228
20.229 @@ -465,25 +465,25 @@
20.230
20.231
20.232 SmartGraphBase()
20.233 - : nodes(), arcs() {}
20.234 + : _nodes(), _arcs() {}
20.235
20.236 typedef True NodeNumTag;
20.237 typedef True EdgeNumTag;
20.238 typedef True ArcNumTag;
20.239
20.240 - int nodeNum() const { return nodes.size(); }
20.241 - int edgeNum() const { return arcs.size() / 2; }
20.242 - int arcNum() const { return arcs.size(); }
20.243 + int nodeNum() const { return _nodes.size(); }
20.244 + int edgeNum() const { return _arcs.size() / 2; }
20.245 + int arcNum() const { return _arcs.size(); }
20.246
20.247 - int maxNodeId() const { return nodes.size()-1; }
20.248 - int maxEdgeId() const { return arcs.size() / 2 - 1; }
20.249 - int maxArcId() const { return arcs.size()-1; }
20.250 + int maxNodeId() const { return _nodes.size()-1; }
20.251 + int maxEdgeId() const { return _arcs.size() / 2 - 1; }
20.252 + int maxArcId() const { return _arcs.size()-1; }
20.253
20.254 - Node source(Arc e) const { return Node(arcs[e._id ^ 1].target); }
20.255 - Node target(Arc e) const { return Node(arcs[e._id].target); }
20.256 + Node source(Arc e) const { return Node(_arcs[e._id ^ 1].target); }
20.257 + Node target(Arc e) const { return Node(_arcs[e._id].target); }
20.258
20.259 - Node u(Edge e) const { return Node(arcs[2 * e._id].target); }
20.260 - Node v(Edge e) const { return Node(arcs[2 * e._id + 1].target); }
20.261 + Node u(Edge e) const { return Node(_arcs[2 * e._id].target); }
20.262 + Node v(Edge e) const { return Node(_arcs[2 * e._id + 1].target); }
20.263
20.264 static bool direction(Arc e) {
20.265 return (e._id & 1) == 1;
20.266 @@ -494,7 +494,7 @@
20.267 }
20.268
20.269 void first(Node& node) const {
20.270 - node._id = nodes.size() - 1;
20.271 + node._id = _nodes.size() - 1;
20.272 }
20.273
20.274 static void next(Node& node) {
20.275 @@ -502,7 +502,7 @@
20.276 }
20.277
20.278 void first(Arc& arc) const {
20.279 - arc._id = arcs.size() - 1;
20.280 + arc._id = _arcs.size() - 1;
20.281 }
20.282
20.283 static void next(Arc& arc) {
20.284 @@ -510,7 +510,7 @@
20.285 }
20.286
20.287 void first(Edge& arc) const {
20.288 - arc._id = arcs.size() / 2 - 1;
20.289 + arc._id = _arcs.size() / 2 - 1;
20.290 }
20.291
20.292 static void next(Edge& arc) {
20.293 @@ -518,23 +518,23 @@
20.294 }
20.295
20.296 void firstOut(Arc &arc, const Node& v) const {
20.297 - arc._id = nodes[v._id].first_out;
20.298 + arc._id = _nodes[v._id].first_out;
20.299 }
20.300 void nextOut(Arc &arc) const {
20.301 - arc._id = arcs[arc._id].next_out;
20.302 + arc._id = _arcs[arc._id].next_out;
20.303 }
20.304
20.305 void firstIn(Arc &arc, const Node& v) const {
20.306 - arc._id = ((nodes[v._id].first_out) ^ 1);
20.307 + arc._id = ((_nodes[v._id].first_out) ^ 1);
20.308 if (arc._id == -2) arc._id = -1;
20.309 }
20.310 void nextIn(Arc &arc) const {
20.311 - arc._id = ((arcs[arc._id ^ 1].next_out) ^ 1);
20.312 + arc._id = ((_arcs[arc._id ^ 1].next_out) ^ 1);
20.313 if (arc._id == -2) arc._id = -1;
20.314 }
20.315
20.316 void firstInc(Edge &arc, bool& d, const Node& v) const {
20.317 - int de = nodes[v._id].first_out;
20.318 + int de = _nodes[v._id].first_out;
20.319 if (de != -1) {
20.320 arc._id = de / 2;
20.321 d = ((de & 1) == 1);
20.322 @@ -544,7 +544,7 @@
20.323 }
20.324 }
20.325 void nextInc(Edge &arc, bool& d) const {
20.326 - int de = (arcs[(arc._id * 2) | (d ? 1 : 0)].next_out);
20.327 + int de = (_arcs[(arc._id * 2) | (d ? 1 : 0)].next_out);
20.328 if (de != -1) {
20.329 arc._id = de / 2;
20.330 d = ((de & 1) == 1);
20.331 @@ -563,43 +563,43 @@
20.332 static Edge edgeFromId(int id) { return Edge(id);}
20.333
20.334 bool valid(Node n) const {
20.335 - return n._id >= 0 && n._id < static_cast<int>(nodes.size());
20.336 + return n._id >= 0 && n._id < static_cast<int>(_nodes.size());
20.337 }
20.338 bool valid(Arc a) const {
20.339 - return a._id >= 0 && a._id < static_cast<int>(arcs.size());
20.340 + return a._id >= 0 && a._id < static_cast<int>(_arcs.size());
20.341 }
20.342 bool valid(Edge e) const {
20.343 - return e._id >= 0 && 2 * e._id < static_cast<int>(arcs.size());
20.344 + return e._id >= 0 && 2 * e._id < static_cast<int>(_arcs.size());
20.345 }
20.346
20.347 Node addNode() {
20.348 - int n = nodes.size();
20.349 - nodes.push_back(NodeT());
20.350 - nodes[n].first_out = -1;
20.351 + int n = _nodes.size();
20.352 + _nodes.push_back(NodeT());
20.353 + _nodes[n].first_out = -1;
20.354
20.355 return Node(n);
20.356 }
20.357
20.358 Edge addEdge(Node u, Node v) {
20.359 - int n = arcs.size();
20.360 - arcs.push_back(ArcT());
20.361 - arcs.push_back(ArcT());
20.362 + int n = _arcs.size();
20.363 + _arcs.push_back(ArcT());
20.364 + _arcs.push_back(ArcT());
20.365
20.366 - arcs[n].target = u._id;
20.367 - arcs[n | 1].target = v._id;
20.368 + _arcs[n].target = u._id;
20.369 + _arcs[n | 1].target = v._id;
20.370
20.371 - arcs[n].next_out = nodes[v._id].first_out;
20.372 - nodes[v._id].first_out = n;
20.373 + _arcs[n].next_out = _nodes[v._id].first_out;
20.374 + _nodes[v._id].first_out = n;
20.375
20.376 - arcs[n | 1].next_out = nodes[u._id].first_out;
20.377 - nodes[u._id].first_out = (n | 1);
20.378 + _arcs[n | 1].next_out = _nodes[u._id].first_out;
20.379 + _nodes[u._id].first_out = (n | 1);
20.380
20.381 return Edge(n / 2);
20.382 }
20.383
20.384 void clear() {
20.385 - arcs.clear();
20.386 - nodes.clear();
20.387 + _arcs.clear();
20.388 + _nodes.clear();
20.389 }
20.390
20.391 };
20.392 @@ -701,7 +701,7 @@
20.393 /// then it is worth reserving space for this amount before starting
20.394 /// to build the graph.
20.395 /// \sa reserveEdge()
20.396 - void reserveNode(int n) { nodes.reserve(n); };
20.397 + void reserveNode(int n) { _nodes.reserve(n); };
20.398
20.399 /// Reserve memory for edges.
20.400
20.401 @@ -711,7 +711,7 @@
20.402 /// then it is worth reserving space for this amount before starting
20.403 /// to build the graph.
20.404 /// \sa reserveNode()
20.405 - void reserveEdge(int m) { arcs.reserve(2 * m); };
20.406 + void reserveEdge(int m) { _arcs.reserve(2 * m); };
20.407
20.408 public:
20.409
20.410 @@ -722,30 +722,30 @@
20.411 void saveSnapshot(Snapshot &s)
20.412 {
20.413 s._graph = this;
20.414 - s.node_num = nodes.size();
20.415 - s.arc_num = arcs.size();
20.416 + s.node_num = _nodes.size();
20.417 + s.arc_num = _arcs.size();
20.418 }
20.419
20.420 void restoreSnapshot(const Snapshot &s)
20.421 {
20.422 - while(s.arc_num<arcs.size()) {
20.423 - int n=arcs.size()-1;
20.424 + while(s.arc_num<_arcs.size()) {
20.425 + int n=_arcs.size()-1;
20.426 Edge arc=edgeFromId(n/2);
20.427 Parent::notifier(Edge()).erase(arc);
20.428 std::vector<Arc> dir;
20.429 dir.push_back(arcFromId(n));
20.430 dir.push_back(arcFromId(n-1));
20.431 Parent::notifier(Arc()).erase(dir);
20.432 - nodes[arcs[n-1].target].first_out=arcs[n].next_out;
20.433 - nodes[arcs[n].target].first_out=arcs[n-1].next_out;
20.434 - arcs.pop_back();
20.435 - arcs.pop_back();
20.436 + _nodes[_arcs[n-1].target].first_out=_arcs[n].next_out;
20.437 + _nodes[_arcs[n].target].first_out=_arcs[n-1].next_out;
20.438 + _arcs.pop_back();
20.439 + _arcs.pop_back();
20.440 }
20.441 - while(s.node_num<nodes.size()) {
20.442 - int n=nodes.size()-1;
20.443 + while(s.node_num<_nodes.size()) {
20.444 + int n=_nodes.size()-1;
20.445 Node node = nodeFromId(n);
20.446 Parent::notifier(Node()).erase(node);
20.447 - nodes.pop_back();
20.448 + _nodes.pop_back();
20.449 }
20.450 }
20.451
20.452 @@ -825,8 +825,8 @@
20.453 int next_out;
20.454 };
20.455
20.456 - std::vector<NodeT> nodes;
20.457 - std::vector<ArcT> arcs;
20.458 + std::vector<NodeT> _nodes;
20.459 + std::vector<ArcT> _arcs;
20.460
20.461 int first_red, first_blue;
20.462 int max_red, max_blue;
20.463 @@ -915,39 +915,39 @@
20.464
20.465
20.466 SmartBpGraphBase()
20.467 - : nodes(), arcs(), first_red(-1), first_blue(-1),
20.468 + : _nodes(), _arcs(), first_red(-1), first_blue(-1),
20.469 max_red(-1), max_blue(-1) {}
20.470
20.471 typedef True NodeNumTag;
20.472 typedef True EdgeNumTag;
20.473 typedef True ArcNumTag;
20.474
20.475 - int nodeNum() const { return nodes.size(); }
20.476 + int nodeNum() const { return _nodes.size(); }
20.477 int redNum() const { return max_red + 1; }
20.478 int blueNum() const { return max_blue + 1; }
20.479 - int edgeNum() const { return arcs.size() / 2; }
20.480 - int arcNum() const { return arcs.size(); }
20.481 + int edgeNum() const { return _arcs.size() / 2; }
20.482 + int arcNum() const { return _arcs.size(); }
20.483
20.484 - int maxNodeId() const { return nodes.size()-1; }
20.485 + int maxNodeId() const { return _nodes.size()-1; }
20.486 int maxRedId() const { return max_red; }
20.487 int maxBlueId() const { return max_blue; }
20.488 - int maxEdgeId() const { return arcs.size() / 2 - 1; }
20.489 - int maxArcId() const { return arcs.size()-1; }
20.490 + int maxEdgeId() const { return _arcs.size() / 2 - 1; }
20.491 + int maxArcId() const { return _arcs.size()-1; }
20.492
20.493 - bool red(Node n) const { return nodes[n._id].red; }
20.494 - bool blue(Node n) const { return !nodes[n._id].red; }
20.495 + bool red(Node n) const { return _nodes[n._id].red; }
20.496 + bool blue(Node n) const { return !_nodes[n._id].red; }
20.497
20.498 static RedNode asRedNodeUnsafe(Node n) { return RedNode(n._id); }
20.499 static BlueNode asBlueNodeUnsafe(Node n) { return BlueNode(n._id); }
20.500
20.501 - Node source(Arc a) const { return Node(arcs[a._id ^ 1].target); }
20.502 - Node target(Arc a) const { return Node(arcs[a._id].target); }
20.503 + Node source(Arc a) const { return Node(_arcs[a._id ^ 1].target); }
20.504 + Node target(Arc a) const { return Node(_arcs[a._id].target); }
20.505
20.506 RedNode redNode(Edge e) const {
20.507 - return RedNode(arcs[2 * e._id].target);
20.508 + return RedNode(_arcs[2 * e._id].target);
20.509 }
20.510 BlueNode blueNode(Edge e) const {
20.511 - return BlueNode(arcs[2 * e._id + 1].target);
20.512 + return BlueNode(_arcs[2 * e._id + 1].target);
20.513 }
20.514
20.515 static bool direction(Arc a) {
20.516 @@ -959,7 +959,7 @@
20.517 }
20.518
20.519 void first(Node& node) const {
20.520 - node._id = nodes.size() - 1;
20.521 + node._id = _nodes.size() - 1;
20.522 }
20.523
20.524 static void next(Node& node) {
20.525 @@ -971,7 +971,7 @@
20.526 }
20.527
20.528 void next(RedNode& node) const {
20.529 - node._id = nodes[node._id].partition_next;
20.530 + node._id = _nodes[node._id].partition_next;
20.531 }
20.532
20.533 void first(BlueNode& node) const {
20.534 @@ -979,11 +979,11 @@
20.535 }
20.536
20.537 void next(BlueNode& node) const {
20.538 - node._id = nodes[node._id].partition_next;
20.539 + node._id = _nodes[node._id].partition_next;
20.540 }
20.541
20.542 void first(Arc& arc) const {
20.543 - arc._id = arcs.size() - 1;
20.544 + arc._id = _arcs.size() - 1;
20.545 }
20.546
20.547 static void next(Arc& arc) {
20.548 @@ -991,7 +991,7 @@
20.549 }
20.550
20.551 void first(Edge& arc) const {
20.552 - arc._id = arcs.size() / 2 - 1;
20.553 + arc._id = _arcs.size() / 2 - 1;
20.554 }
20.555
20.556 static void next(Edge& arc) {
20.557 @@ -999,23 +999,23 @@
20.558 }
20.559
20.560 void firstOut(Arc &arc, const Node& v) const {
20.561 - arc._id = nodes[v._id].first_out;
20.562 + arc._id = _nodes[v._id].first_out;
20.563 }
20.564 void nextOut(Arc &arc) const {
20.565 - arc._id = arcs[arc._id].next_out;
20.566 + arc._id = _arcs[arc._id].next_out;
20.567 }
20.568
20.569 void firstIn(Arc &arc, const Node& v) const {
20.570 - arc._id = ((nodes[v._id].first_out) ^ 1);
20.571 + arc._id = ((_nodes[v._id].first_out) ^ 1);
20.572 if (arc._id == -2) arc._id = -1;
20.573 }
20.574 void nextIn(Arc &arc) const {
20.575 - arc._id = ((arcs[arc._id ^ 1].next_out) ^ 1);
20.576 + arc._id = ((_arcs[arc._id ^ 1].next_out) ^ 1);
20.577 if (arc._id == -2) arc._id = -1;
20.578 }
20.579
20.580 void firstInc(Edge &arc, bool& d, const Node& v) const {
20.581 - int de = nodes[v._id].first_out;
20.582 + int de = _nodes[v._id].first_out;
20.583 if (de != -1) {
20.584 arc._id = de / 2;
20.585 d = ((de & 1) == 1);
20.586 @@ -1025,7 +1025,7 @@
20.587 }
20.588 }
20.589 void nextInc(Edge &arc, bool& d) const {
20.590 - int de = (arcs[(arc._id * 2) | (d ? 1 : 0)].next_out);
20.591 + int de = (_arcs[(arc._id * 2) | (d ? 1 : 0)].next_out);
20.592 if (de != -1) {
20.593 arc._id = de / 2;
20.594 d = ((de & 1) == 1);
20.595 @@ -1036,8 +1036,8 @@
20.596 }
20.597
20.598 static int id(Node v) { return v._id; }
20.599 - int id(RedNode v) const { return nodes[v._id].partition_index; }
20.600 - int id(BlueNode v) const { return nodes[v._id].partition_index; }
20.601 + int id(RedNode v) const { return _nodes[v._id].partition_index; }
20.602 + int id(BlueNode v) const { return _nodes[v._id].partition_index; }
20.603 static int id(Arc e) { return e._id; }
20.604 static int id(Edge e) { return e._id; }
20.605
20.606 @@ -1046,59 +1046,59 @@
20.607 static Edge edgeFromId(int id) { return Edge(id);}
20.608
20.609 bool valid(Node n) const {
20.610 - return n._id >= 0 && n._id < static_cast<int>(nodes.size());
20.611 + return n._id >= 0 && n._id < static_cast<int>(_nodes.size());
20.612 }
20.613 bool valid(Arc a) const {
20.614 - return a._id >= 0 && a._id < static_cast<int>(arcs.size());
20.615 + return a._id >= 0 && a._id < static_cast<int>(_arcs.size());
20.616 }
20.617 bool valid(Edge e) const {
20.618 - return e._id >= 0 && 2 * e._id < static_cast<int>(arcs.size());
20.619 + return e._id >= 0 && 2 * e._id < static_cast<int>(_arcs.size());
20.620 }
20.621
20.622 RedNode addRedNode() {
20.623 - int n = nodes.size();
20.624 - nodes.push_back(NodeT());
20.625 - nodes[n].first_out = -1;
20.626 - nodes[n].red = true;
20.627 - nodes[n].partition_index = ++max_red;
20.628 - nodes[n].partition_next = first_red;
20.629 + int n = _nodes.size();
20.630 + _nodes.push_back(NodeT());
20.631 + _nodes[n].first_out = -1;
20.632 + _nodes[n].red = true;
20.633 + _nodes[n].partition_index = ++max_red;
20.634 + _nodes[n].partition_next = first_red;
20.635 first_red = n;
20.636
20.637 return RedNode(n);
20.638 }
20.639
20.640 BlueNode addBlueNode() {
20.641 - int n = nodes.size();
20.642 - nodes.push_back(NodeT());
20.643 - nodes[n].first_out = -1;
20.644 - nodes[n].red = false;
20.645 - nodes[n].partition_index = ++max_blue;
20.646 - nodes[n].partition_next = first_blue;
20.647 + int n = _nodes.size();
20.648 + _nodes.push_back(NodeT());
20.649 + _nodes[n].first_out = -1;
20.650 + _nodes[n].red = false;
20.651 + _nodes[n].partition_index = ++max_blue;
20.652 + _nodes[n].partition_next = first_blue;
20.653 first_blue = n;
20.654
20.655 return BlueNode(n);
20.656 }
20.657
20.658 Edge addEdge(RedNode u, BlueNode v) {
20.659 - int n = arcs.size();
20.660 - arcs.push_back(ArcT());
20.661 - arcs.push_back(ArcT());
20.662 + int n = _arcs.size();
20.663 + _arcs.push_back(ArcT());
20.664 + _arcs.push_back(ArcT());
20.665
20.666 - arcs[n].target = u._id;
20.667 - arcs[n | 1].target = v._id;
20.668 + _arcs[n].target = u._id;
20.669 + _arcs[n | 1].target = v._id;
20.670
20.671 - arcs[n].next_out = nodes[v._id].first_out;
20.672 - nodes[v._id].first_out = n;
20.673 + _arcs[n].next_out = _nodes[v._id].first_out;
20.674 + _nodes[v._id].first_out = n;
20.675
20.676 - arcs[n | 1].next_out = nodes[u._id].first_out;
20.677 - nodes[u._id].first_out = (n | 1);
20.678 + _arcs[n | 1].next_out = _nodes[u._id].first_out;
20.679 + _nodes[u._id].first_out = (n | 1);
20.680
20.681 return Edge(n / 2);
20.682 }
20.683
20.684 void clear() {
20.685 - arcs.clear();
20.686 - nodes.clear();
20.687 + _arcs.clear();
20.688 + _nodes.clear();
20.689 first_red = -1;
20.690 first_blue = -1;
20.691 max_blue = -1;
20.692 @@ -1213,7 +1213,7 @@
20.693 /// then it is worth reserving space for this amount before starting
20.694 /// to build the graph.
20.695 /// \sa reserveEdge()
20.696 - void reserveNode(int n) { nodes.reserve(n); };
20.697 + void reserveNode(int n) { _nodes.reserve(n); };
20.698
20.699 /// Reserve memory for edges.
20.700
20.701 @@ -1223,7 +1223,7 @@
20.702 /// then it is worth reserving space for this amount before starting
20.703 /// to build the graph.
20.704 /// \sa reserveNode()
20.705 - void reserveEdge(int m) { arcs.reserve(2 * m); };
20.706 + void reserveEdge(int m) { _arcs.reserve(2 * m); };
20.707
20.708 public:
20.709
20.710 @@ -1234,47 +1234,47 @@
20.711 void saveSnapshot(Snapshot &s)
20.712 {
20.713 s._graph = this;
20.714 - s.node_num = nodes.size();
20.715 - s.arc_num = arcs.size();
20.716 + s.node_num = _nodes.size();
20.717 + s.arc_num = _arcs.size();
20.718 }
20.719
20.720 void restoreSnapshot(const Snapshot &s)
20.721 {
20.722 - while(s.arc_num<arcs.size()) {
20.723 - int n=arcs.size()-1;
20.724 + while(s.arc_num<_arcs.size()) {
20.725 + int n=_arcs.size()-1;
20.726 Edge arc=edgeFromId(n/2);
20.727 Parent::notifier(Edge()).erase(arc);
20.728 std::vector<Arc> dir;
20.729 dir.push_back(arcFromId(n));
20.730 dir.push_back(arcFromId(n-1));
20.731 Parent::notifier(Arc()).erase(dir);
20.732 - nodes[arcs[n-1].target].first_out=arcs[n].next_out;
20.733 - nodes[arcs[n].target].first_out=arcs[n-1].next_out;
20.734 - arcs.pop_back();
20.735 - arcs.pop_back();
20.736 + _nodes[_arcs[n-1].target].first_out=_arcs[n].next_out;
20.737 + _nodes[_arcs[n].target].first_out=_arcs[n-1].next_out;
20.738 + _arcs.pop_back();
20.739 + _arcs.pop_back();
20.740 }
20.741 - while(s.node_num<nodes.size()) {
20.742 - int n=nodes.size()-1;
20.743 + while(s.node_num<_nodes.size()) {
20.744 + int n=_nodes.size()-1;
20.745 Node node = nodeFromId(n);
20.746 if (Parent::red(node)) {
20.747 - first_red = nodes[n].partition_next;
20.748 + first_red = _nodes[n].partition_next;
20.749 if (first_red != -1) {
20.750 - max_red = nodes[first_red].partition_index;
20.751 + max_red = _nodes[first_red].partition_index;
20.752 } else {
20.753 max_red = -1;
20.754 }
20.755 Parent::notifier(RedNode()).erase(asRedNodeUnsafe(node));
20.756 } else {
20.757 - first_blue = nodes[n].partition_next;
20.758 + first_blue = _nodes[n].partition_next;
20.759 if (first_blue != -1) {
20.760 - max_blue = nodes[first_blue].partition_index;
20.761 + max_blue = _nodes[first_blue].partition_index;
20.762 } else {
20.763 max_blue = -1;
20.764 }
20.765 Parent::notifier(BlueNode()).erase(asBlueNodeUnsafe(node));
20.766 }
20.767 Parent::notifier(Node()).erase(node);
20.768 - nodes.pop_back();
20.769 + _nodes.pop_back();
20.770 }
20.771 }
20.772
21.1 --- a/lemon/soplex.cc Thu Apr 02 22:34:03 2015 +0200
21.2 +++ b/lemon/soplex.cc Sun Jan 05 22:24:56 2014 +0100
21.3 @@ -37,8 +37,8 @@
21.4 }
21.5
21.6 SoplexLp::SoplexLp(const SoplexLp& lp) {
21.7 - rows = lp.rows;
21.8 - cols = lp.cols;
21.9 + _rows = lp._rows;
21.10 + _cols = lp._cols;
21.11
21.12 soplex = new soplex::SoPlex;
21.13 (*static_cast<soplex::SPxLP*>(soplex)) = *(lp.soplex);
21.14 @@ -122,12 +122,12 @@
21.15 }
21.16
21.17 void SoplexLp::_eraseColId(int i) {
21.18 - cols.eraseIndex(i);
21.19 - cols.relocateIndex(i, cols.maxIndex());
21.20 + _cols.eraseIndex(i);
21.21 + _cols.relocateIndex(i, _cols.maxIndex());
21.22 }
21.23 void SoplexLp::_eraseRowId(int i) {
21.24 - rows.eraseIndex(i);
21.25 - rows.relocateIndex(i, rows.maxIndex());
21.26 + _rows.eraseIndex(i);
21.27 + _rows.relocateIndex(i, _rows.maxIndex());
21.28 }
21.29
21.30 void SoplexLp::_getColName(int c, std::string &name) const {
21.31 @@ -432,8 +432,8 @@
21.32 _col_names_ref.clear();
21.33 _row_names.clear();
21.34 _row_names_ref.clear();
21.35 - cols.clear();
21.36 - rows.clear();
21.37 + _cols.clear();
21.38 + _rows.clear();
21.39 _clear_temporals();
21.40 }
21.41