[Lemon-commits] Gabor Gevay: STL style iterators (#325)
Lemon HG
hg at lemon.cs.elte.hu
Tue Apr 14 20:42:49 CEST 2015
details: http://lemon.cs.elte.hu/hg/lemon/rev/0759d974de81
changeset: 1336:0759d974de81
user: Gabor Gevay <ggab90 [at] gmail.com>
date: Sun Jan 05 22:24:56 2014 +0100
description:
STL style iterators (#325)
For
* graph types,
* graph adaptors,
* paths,
* iterable maps,
* LP rows/cols and
* active nodes is BellmanFord
diffstat:
CMakeLists.txt | 8 +
lemon/bellman_ford.h | 16 +
lemon/bits/graph_adaptor_extender.h | 41 +
lemon/bits/graph_extender.h | 81 +++
lemon/bits/stl_iterators.h | 99 ++++
lemon/cbc.cc | 4 +-
lemon/clp.cc | 12 +-
lemon/clp.h | 4 +-
lemon/concepts/bpgraph.h | 138 ++++++
lemon/concepts/digraph.h | 83 +++
lemon/concepts/graph.h | 125 +++++
lemon/concepts/path.h | 53 ++
lemon/cplex.cc | 12 +-
lemon/glpk.cc | 12 +-
lemon/glpk.h | 4 +-
lemon/list_graph.h | 766 ++++++++++++++++++------------------
lemon/lp_base.h | 152 ++++--
lemon/maps.h | 50 ++
lemon/path.h | 116 ++++-
lemon/smart_graph.h | 344 ++++++++--------
lemon/soplex.cc | 16 +-
21 files changed, 1475 insertions(+), 661 deletions(-)
diffs (truncated from 4192 to 300 lines):
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -262,6 +262,14 @@
ENABLE_TESTING()
+
+INCLUDE(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++11" CXX11FLAG)
+IF(CXX11FLAG)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ENDIF()
+
+
IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
ELSE()
diff --git a/lemon/bellman_ford.h b/lemon/bellman_ford.h
--- a/lemon/bellman_ford.h
+++ b/lemon/bellman_ford.h
@@ -29,6 +29,7 @@
#include <lemon/error.h>
#include <lemon/maps.h>
#include <lemon/path.h>
+#include <lemon/bits/stl_iterators.h>
#include <limits>
@@ -690,6 +691,21 @@
int _index;
};
+ /// \brief Gets the collection of the active nodes.
+ ///
+ /// This function can be used for iterating on the active nodes of the
+ /// Bellman-Ford algorithm after the last phase.
+ /// These nodes should be checked in the next phase to
+ /// find augmenting arcs outgoing from them.
+ /// It returns a wrapped ActiveIt, which looks
+ /// like an STL container (by having begin() and end())
+ /// which you can use in range-based for loops, STL algorithms, etc.
+ LemonRangeWrapper1<ActiveIt, BellmanFord>
+ activeNodes(const BellmanFord& algorithm) const {
+ return LemonRangeWrapper1<ActiveIt, BellmanFord>(algorithm);
+ }
+
+
/// \name Query Functions
/// The result of the Bellman-Ford algorithm can be obtained using these
/// functions.\n
diff --git a/lemon/bits/graph_adaptor_extender.h b/lemon/bits/graph_adaptor_extender.h
--- a/lemon/bits/graph_adaptor_extender.h
+++ b/lemon/bits/graph_adaptor_extender.h
@@ -85,6 +85,9 @@
};
+ LemonRangeWrapper1<NodeIt, Adaptor> nodes() {
+ return LemonRangeWrapper1<NodeIt, Adaptor>(*this);
+ }
class ArcIt : public Arc {
const Adaptor* _adaptor;
@@ -108,6 +111,10 @@
};
+ LemonRangeWrapper1<ArcIt, Adaptor> arcs() {
+ return LemonRangeWrapper1<ArcIt, Adaptor>(*this);
+ }
+
class OutArcIt : public Arc {
const Adaptor* _adaptor;
@@ -132,6 +139,10 @@
};
+ LemonRangeWrapper2<OutArcIt, Adaptor, Node> outArcs(const Node& u) const {
+ return LemonRangeWrapper2<OutArcIt, Adaptor, Node>(*this, u);
+ }
+
class InArcIt : public Arc {
const Adaptor* _adaptor;
@@ -156,6 +167,10 @@
};
+ LemonRangeWrapper2<InArcIt, Adaptor, Node> inArcs(const Node& u) const {
+ return LemonRangeWrapper2<InArcIt, Adaptor, Node>(*this, u);
+ }
+
Node baseNode(const OutArcIt &e) const {
return Parent::source(e);
}
@@ -254,6 +269,10 @@
};
+ LemonRangeWrapper1<NodeIt, Adaptor> nodes() {
+ return LemonRangeWrapper1<NodeIt, Adaptor>(*this);
+ }
+
class ArcIt : public Arc {
const Adaptor* _adaptor;
@@ -277,6 +296,10 @@
};
+ LemonRangeWrapper1<ArcIt, Adaptor> arcs() {
+ return LemonRangeWrapper1<ArcIt, Adaptor>(*this);
+ }
+
class OutArcIt : public Arc {
const Adaptor* _adaptor;
@@ -301,6 +324,10 @@
};
+ LemonRangeWrapper2<OutArcIt, Adaptor, Node> outArcs(const Node& u) const {
+ return LemonRangeWrapper2<OutArcIt, Adaptor, Node>(*this, u);
+ }
+
class InArcIt : public Arc {
const Adaptor* _adaptor;
@@ -325,6 +352,10 @@
};
+ LemonRangeWrapper2<InArcIt, Adaptor, Node> inArcs(const Node& u) const {
+ return LemonRangeWrapper2<InArcIt, Adaptor, Node>(*this, u);
+ }
+
class EdgeIt : public Parent::Edge {
const Adaptor* _adaptor;
public:
@@ -347,6 +378,11 @@
};
+ LemonRangeWrapper1<EdgeIt, Adaptor> edges() {
+ return LemonRangeWrapper1<EdgeIt, Adaptor>(*this);
+ }
+
+
class IncEdgeIt : public Edge {
friend class GraphAdaptorExtender;
const Adaptor* _adaptor;
@@ -372,6 +408,11 @@
}
};
+ LemonRangeWrapper2<IncEdgeIt, Adaptor, Node> incEdges(const Node& u) const {
+ return LemonRangeWrapper2<IncEdgeIt, Adaptor, Node>(*this, u);
+ }
+
+
Node baseNode(const OutArcIt &a) const {
return Parent::source(a);
}
diff --git a/lemon/bits/graph_extender.h b/lemon/bits/graph_extender.h
--- a/lemon/bits/graph_extender.h
+++ b/lemon/bits/graph_extender.h
@@ -27,6 +27,8 @@
#include <lemon/concept_check.h>
#include <lemon/concepts/maps.h>
+#include <lemon/bits/stl_iterators.h>
+
//\ingroup graphbits
//\file
//\brief Extenders for the graph types
@@ -116,6 +118,10 @@
};
+ LemonRangeWrapper1<NodeIt, Digraph> nodes() const {
+ return LemonRangeWrapper1<NodeIt, Digraph>(*this);
+ }
+
class ArcIt : public Arc {
const Digraph* _digraph;
@@ -139,6 +145,10 @@
};
+ LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
+ return LemonRangeWrapper1<ArcIt, Digraph>(*this);
+ }
+
class OutArcIt : public Arc {
const Digraph* _digraph;
@@ -163,6 +173,10 @@
};
+ LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
+ return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
+ }
+
class InArcIt : public Arc {
const Digraph* _digraph;
@@ -187,6 +201,10 @@
};
+ LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
+ return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
+ }
+
// \brief Base node of the iterator
//
// Returns the base node (i.e. the source in this case) of the iterator
@@ -436,6 +454,10 @@
};
+ LemonRangeWrapper1<NodeIt, Graph> nodes() const {
+ return LemonRangeWrapper1<NodeIt, Graph>(*this);
+ }
+
class ArcIt : public Arc {
const Graph* _graph;
@@ -459,6 +481,10 @@
};
+ LemonRangeWrapper1<ArcIt, Graph> arcs() const {
+ return LemonRangeWrapper1<ArcIt, Graph>(*this);
+ }
+
class OutArcIt : public Arc {
const Graph* _graph;
@@ -483,6 +509,10 @@
};
+ LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
+ return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
+ }
+
class InArcIt : public Arc {
const Graph* _graph;
@@ -507,6 +537,10 @@
};
+ LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
+ return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
+ }
+
class EdgeIt : public Parent::Edge {
const Graph* _graph;
@@ -530,6 +564,11 @@
};
+ LemonRangeWrapper1<EdgeIt, Graph> edges() const {
+ return LemonRangeWrapper1<EdgeIt, Graph>(*this);
+ }
+
+
class IncEdgeIt : public Parent::Edge {
friend class GraphExtender;
const Graph* _graph;
@@ -555,6 +594,11 @@
}
};
+ LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
+ return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
+ }
+
+
// \brief Base node of the iterator
//
// Returns the base node (ie. the source in this case) of the iterator
@@ -903,6 +947,11 @@
};
+ LemonRangeWrapper1<NodeIt, BpGraph> nodes() const {
+ return LemonRangeWrapper1<NodeIt, BpGraph>(*this);
+ }
+
+
class RedNodeIt : public RedNode {
const BpGraph* _graph;
More information about the Lemon-commits
mailing list