Commit 7fb5d71d authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Dump lambda::bind in favor of boost::bind

This is a large commit which replaces lambda::bind with boost::bind in
most parts of the code. This improves compilation time, and slightly
decreases compilation memory usage in some cases.
parent a89e069c
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <boost/mpl/find.hpp> #include <boost/mpl/find.hpp>
#include <boost/mpl/for_each.hpp> #include <boost/mpl/for_each.hpp>
#include <boost/python/object.hpp> #include <boost/python/object.hpp>
#include <boost/lambda/bind.hpp> #include <boost/bind.hpp>
#include <exception> #include <exception>
namespace boost namespace boost
...@@ -292,11 +292,10 @@ struct get_string ...@@ -292,11 +292,10 @@ struct get_string
template <typename ValueTypes, typename Descriptor> template <typename ValueTypes, typename Descriptor>
std::string print_value(dynamic_property_map& pmap, Descriptor v) std::string print_value(dynamic_property_map& pmap, Descriptor v)
{ {
using namespace boost::lambda;
std::string val; std::string val;
boost::any oval = pmap.get(v); boost::any oval = pmap.get(v);
mpl::for_each<ValueTypes>(bind<void>(get_string(), var(oval), mpl::for_each<ValueTypes>(bind<void>(get_string(), ref(oval),
var(val), _1)); ref(val), _1));
return val; return val;
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/graph/betweenness_centrality.hpp> #include <boost/graph/betweenness_centrality.hpp>
#include "graph.hh" #include "graph.hh"
...@@ -27,7 +26,6 @@ ...@@ -27,7 +26,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
template <class Graph, class EdgeBetweenness, class VertexBetweenness> template <class Graph, class EdgeBetweenness, class VertexBetweenness>
...@@ -139,9 +137,9 @@ void betweenness(GraphInterface& g, boost::any weight, ...@@ -139,9 +137,9 @@ void betweenness(GraphInterface& g, boost::any weight,
if (!weight.empty()) if (!weight.empty())
{ {
run_action<>() run_action<>()
(g, lambda::bind<void> (g, bind<void>
(get_weighted_betweenness(), lambda::_1, g.GetVertexIndex(), (get_weighted_betweenness(), _1, g.GetVertexIndex(),
lambda::_2, lambda::_3, weight, normalize, _2, _3, weight, normalize,
g.GetNumberOfVertices(), g.GetMaxEdgeIndex()), g.GetNumberOfVertices(), g.GetMaxEdgeIndex()),
edge_floating_properties(), edge_floating_properties(),
vertex_floating_properties()) vertex_floating_properties())
...@@ -150,9 +148,8 @@ void betweenness(GraphInterface& g, boost::any weight, ...@@ -150,9 +148,8 @@ void betweenness(GraphInterface& g, boost::any weight,
else else
{ {
run_action<>() run_action<>()
(g, lambda::bind<void> (g, bind<void>(get_betweenness(), _1, g.GetVertexIndex(), _2,
(get_betweenness(), lambda::_1, g.GetVertexIndex(), lambda::_2, _3, normalize, g.GetNumberOfVertices()),
lambda::_3, normalize, g.GetNumberOfVertices()),
edge_floating_properties(), edge_floating_properties(),
vertex_floating_properties()) vertex_floating_properties())
(edge_betweenness, vertex_betweenness); (edge_betweenness, vertex_betweenness);
...@@ -174,8 +171,8 @@ double central_point(GraphInterface& g, ...@@ -174,8 +171,8 @@ double central_point(GraphInterface& g,
{ {
double c = 0.0; double c = 0.0;
run_action<graph_tool::detail::never_reversed>() run_action<graph_tool::detail::never_reversed>()
(g, lambda::bind<void>(get_central_point_dominance(), lambda::_1, (g, bind<void>(get_central_point_dominance(), _1,
lambda::_2, var(c)), _2, ref(c)),
vertex_scalar_properties()) (vertex_betweenness); vertex_scalar_properties()) (vertex_betweenness);
return c; return c;
} }
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/lambda/bind.hpp>
#include "graph.hh" #include "graph.hh"
#include "graph_selectors.hh" #include "graph_selectors.hh"
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
size_t pagerank(GraphInterface& g, boost::any rank, double d, double epslon, size_t pagerank(GraphInterface& g, boost::any rank, double d, double epslon,
...@@ -37,9 +36,9 @@ size_t pagerank(GraphInterface& g, boost::any rank, double d, double epslon, ...@@ -37,9 +36,9 @@ size_t pagerank(GraphInterface& g, boost::any rank, double d, double epslon,
size_t iter; size_t iter;
run_action<>() run_action<>()
(g, lambda::bind<void>(get_pagerank(), (g, bind<void>(get_pagerank(),
lambda::_1, g.GetVertexIndex(), lambda::_2, d, _1, g.GetVertexIndex(), _2, d,
epslon, max_iter, lambda::var(iter)), epslon, max_iter, ref(iter)),
writable_vertex_scalar_properties())(rank); writable_vertex_scalar_properties())(rank);
return iter; return iter;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
python::tuple global_clustering(GraphInterface& g) python::tuple global_clustering(GraphInterface& g)
...@@ -36,8 +35,7 @@ python::tuple global_clustering(GraphInterface& g) ...@@ -36,8 +35,7 @@ python::tuple global_clustering(GraphInterface& g)
bool directed = g.GetDirected(); bool directed = g.GetDirected();
g.SetDirected(false); g.SetDirected(false);
run_action<graph_tool::detail::never_directed>() run_action<graph_tool::detail::never_directed>()
(g, lambda::bind<void>(get_global_clustering(), lambda::_1, (g, bind<void>(get_global_clustering(), _1, ref(c), ref(c_err)))();
lambda::var(c), lambda::var(c_err)))();
g.SetDirected(directed); g.SetDirected(directed);
return python::make_tuple(c, c_err); return python::make_tuple(c, c_err);
} }
...@@ -47,8 +45,7 @@ void local_clustering(GraphInterface& g, boost::any prop) ...@@ -47,8 +45,7 @@ void local_clustering(GraphInterface& g, boost::any prop)
bool directed = g.GetDirected(); bool directed = g.GetDirected();
g.SetDirected(false); g.SetDirected(false);
run_action<graph_tool::detail::never_directed>() run_action<graph_tool::detail::never_directed>()
(g, lambda::bind<void>(set_clustering_to_property(), lambda::_1, (g, bind<void>(set_clustering_to_property(), _1, _2),
lambda::_2),
writable_vertex_scalar_properties())(prop); writable_vertex_scalar_properties())(prop);
g.SetDirected(directed); g.SetDirected(directed);
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
template <class PropertySequence> template <class PropertySequence>
...@@ -37,9 +36,8 @@ struct prop_vector ...@@ -37,9 +36,8 @@ struct prop_vector
{ {
boost::any prop_vec; boost::any prop_vec;
mpl::for_each<PropertySequence> mpl::for_each<PropertySequence>
(lambda::bind<void>(get_prop_vector(), lambda::_1, (bind<void>(get_prop_vector(), _1, ref(props), ref(prop_vec),
lambda::var(props), lambda::var(prop_vec), size));
size));
return prop_vec; return prop_vec;
} }
...@@ -94,9 +92,9 @@ void extended_clustering(GraphInterface& g, python::list props) ...@@ -94,9 +92,9 @@ void extended_clustering(GraphInterface& g, python::list props)
properties_vector; properties_vector;
run_action<>() run_action<>()
(g, lambda::bind<void>(get_extended_clustering(), lambda::_1, (g, bind<void>(get_extended_clustering(), _1,
any_cast<GraphInterface::vertex_index_map_t> any_cast<GraphInterface::vertex_index_map_t>
(g.GetVertexIndex()), lambda::_2), (g.GetVertexIndex()), _2),
properties_vector()) (vprop); properties_vector()) (vprop);
} }
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
struct null_copy struct null_copy
...@@ -89,8 +88,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list, ...@@ -89,8 +88,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
{ {
GraphInterface& sub = GraphInterface& sub =
python::extract<GraphInterface&>(subgraph_list[i]); python::extract<GraphInterface&>(subgraph_list[i]);
run_action<>()(sub, lambda::bind<void>(append_to_list(), lambda::_1, run_action<>()(sub, bind<void>(append_to_list(), _1,
lambda::var(list)))(); ref(list)))();
} }
} }
catch (bad_any_cast&) catch (bad_any_cast&)
...@@ -115,10 +114,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list, ...@@ -115,10 +114,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
sampler = sample_some(plist, rng); sampler = sample_some(plist, rng);
run_action<>() run_action<>()
(g, lambda::bind<void>(get_all_motifs(), lambda::_1, k, (g, bind<void>(get_all_motifs(), _1, k, ref(list), ref(phist), _2,
lambda::var(list), lambda::var(phist), plist[0], comp_iso, fill_list, ref(rng)),
lambda::_2, plist[0], comp_iso,
fill_list, lambda::var(rng)),
mpl::vector<sample_all,sample_some>())(sampler); mpl::vector<sample_all,sample_some>())(sampler);
for (size_t i = 0; i < phist.size(); ++i) for (size_t i = 0; i < phist.size(); ++i)
...@@ -141,8 +138,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list, ...@@ -141,8 +138,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
mpl::bool_<false>,mpl::bool_<true>, mpl::bool_<false>,mpl::bool_<true>,
mpl::bool_<true> >::type gviews; mpl::bool_<true> >::type gviews;
run_action<gviews>() run_action<gviews>()
(sub, lambda::bind<void>(retrieve_from_list(), lambda::_1, (sub, bind<void>(retrieve_from_list(), _1,
lambda::var(list), lambda::var(done)))(); ref(list), ref(done)))();
if (!done) if (!done)
{ {
sub.ReIndexEdges(); sub.ReIndexEdges();
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
#include <boost/lambda/bind.hpp>
#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_back.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
...@@ -28,7 +27,6 @@ ...@@ -28,7 +27,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
...@@ -39,11 +37,6 @@ void community_structure(GraphInterface& g, double gamma, string corr_name, ...@@ -39,11 +37,6 @@ void community_structure(GraphInterface& g, double gamma, string corr_name,
string history_file, boost::any weight, string history_file, boost::any weight,
boost::any property) boost::any property)
{ {
using boost::lambda::bind;
using boost::lambda::_1;
using boost::lambda::_2;
using boost::lambda::_3;
typedef property_map_types::apply<mpl::vector<int32_t,int64_t>, typedef property_map_types::apply<mpl::vector<int32_t,int64_t>,
GraphInterface::vertex_index_map_t, GraphInterface::vertex_index_map_t,
mpl::bool_<false> >::type mpl::bool_<false> >::type
...@@ -87,11 +80,6 @@ void community_structure(GraphInterface& g, double gamma, string corr_name, ...@@ -87,11 +80,6 @@ void community_structure(GraphInterface& g, double gamma, string corr_name,
double modularity(GraphInterface& g, boost::any weight, boost::any property) double modularity(GraphInterface& g, boost::any weight, boost::any property)
{ {
using boost::lambda::bind;
using boost::lambda::_1;
using boost::lambda::_2;
using boost::lambda::_3;
double modularity = 0; double modularity = 0;
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> weight_map_t; typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> weight_map_t;
...@@ -104,7 +92,7 @@ double modularity(GraphInterface& g, boost::any weight, boost::any property) ...@@ -104,7 +92,7 @@ double modularity(GraphInterface& g, boost::any weight, boost::any property)
bool directed = g.GetDirected(); bool directed = g.GetDirected();
g.SetDirected(false); g.SetDirected(false);
run_action<graph_tool::detail::never_directed>() run_action<graph_tool::detail::never_directed>()
(g, bind<void>(get_modularity(), _1, _2, _3, var(modularity)), (g, bind<void>(get_modularity(), _1, _2, _3, ref(modularity)),
edge_props_t(), vertex_scalar_properties()) edge_props_t(), vertex_scalar_properties())
(weight, property); (weight, property);
g.SetDirected(directed); g.SetDirected(directed);
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "graph_selectors.hh" #include "graph_selectors.hh"
#include "graph_properties.hh" #include "graph_properties.hh"
//#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/bind/placeholders.hpp> #include <boost/bind/placeholders.hpp>
#include <boost/mpl/push_back.hpp> #include <boost/mpl/push_back.hpp>
......
...@@ -29,10 +29,9 @@ pair<double,double> ...@@ -29,10 +29,9 @@ pair<double,double>
assortativity_coefficient(GraphInterface& gi, assortativity_coefficient(GraphInterface& gi,
GraphInterface::deg_t deg) GraphInterface::deg_t deg)
{ {
using namespace boost::lambda;
double a, a_err; double a, a_err;
run_action<>()(gi,bind<void>(get_assortativity_coefficient(), _1, _2, run_action<>()(gi,bind<void>(get_assortativity_coefficient(), _1, _2,
var(a), var(a_err)), scalar_selectors()) ref(a), ref(a_err)), scalar_selectors())
(degree_selector(deg)); (degree_selector(deg));
return make_pair(a, a_err); return make_pair(a, a_err);
} }
...@@ -41,10 +40,9 @@ pair<double,double> ...@@ -41,10 +40,9 @@ pair<double,double>
scalar_assortativity_coefficient(GraphInterface& gi, scalar_assortativity_coefficient(GraphInterface& gi,
GraphInterface::deg_t deg) GraphInterface::deg_t deg)
{ {
using namespace boost::lambda;
double a, a_err; double a, a_err;
run_action<>()(gi, bind<void>(get_scalar_assortativity_coefficient(), run_action<>()(gi, bind<void>(get_scalar_assortativity_coefficient(),
_1, _2, var(a), var(a_err)), _1, _2, ref(a), ref(a_err)),
scalar_selectors()) scalar_selectors())
(degree_selector(deg)); (degree_selector(deg));
return make_pair(a, a_err); return make_pair(a, a_err);
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
#include "graph.hh" #include "graph.hh"
...@@ -30,7 +29,6 @@ ...@@ -30,7 +29,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
// implementations spread across different compile units to minimize memory // implementations spread across different compile units to minimize memory
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
#include "graph.hh" #include "graph.hh"
...@@ -30,7 +29,6 @@ ...@@ -30,7 +29,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight; typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight;
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include "graph.hh" #include "graph.hh"
#include "histogram.hh" #include "histogram.hh"
#include "graph_selectors.hh" #include "graph_selectors.hh"
...@@ -28,7 +26,6 @@ ...@@ -28,7 +26,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
void graph_avg_corr_imp1(GraphInterface& g, python::object& avg, void graph_avg_corr_imp1(GraphInterface& g, python::object& avg,
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
#include "graph.hh" #include "graph.hh"
...@@ -31,7 +30,6 @@ ...@@ -31,7 +30,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
// implementations spread across different compile units to minimize memory // implementations spread across different compile units to minimize memory
......
...@@ -32,7 +32,6 @@ namespace graph_tool ...@@ -32,7 +32,6 @@ namespace graph_tool
{ {
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
// get degrees pairs from source and of neighbours // get degrees pairs from source and of neighbours
class GetNeighboursPairs class GetNeighboursPairs
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp> #include <boost/python.hpp>
#include "graph.hh" #include "graph.hh"
...@@ -29,7 +28,6 @@ ...@@ -29,7 +28,6 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
using namespace boost::lambda;
using namespace graph_tool; using namespace graph_tool;
typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight; typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight;
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
#include "graph_filtering.hh" #include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include "graph.hh" #include "graph.hh"
#include "histogram.hh" #include "histogram.hh"
#include "graph_selectors.hh" #include "graph_selectors.hh"
...@@ -28,7 +26,6 @@ ...@@ -28,7 +26,6 @@
using namespace std; using namespace std;
using namespace boost;