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 @@
#include <boost/mpl/find.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/python/object.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp>
#include <exception>
namespace boost
......@@ -292,11 +292,10 @@ struct get_string
template <typename ValueTypes, typename Descriptor>
std::string print_value(dynamic_property_map& pmap, Descriptor v)
{
using namespace boost::lambda;
std::string val;
boost::any oval = pmap.get(v);
mpl::for_each<ValueTypes>(bind<void>(get_string(), var(oval),
var(val), _1));
mpl::for_each<ValueTypes>(bind<void>(get_string(), ref(oval),
ref(val), _1));
return val;
}
......
......@@ -18,7 +18,6 @@
#include "graph_filtering.hh"
#include <boost/python.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/graph/betweenness_centrality.hpp>
#include "graph.hh"
......@@ -27,7 +26,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
template <class Graph, class EdgeBetweenness, class VertexBetweenness>
......@@ -139,9 +137,9 @@ void betweenness(GraphInterface& g, boost::any weight,
if (!weight.empty())
{
run_action<>()
(g, lambda::bind<void>
(get_weighted_betweenness(), lambda::_1, g.GetVertexIndex(),
lambda::_2, lambda::_3, weight, normalize,
(g, bind<void>
(get_weighted_betweenness(), _1, g.GetVertexIndex(),
_2, _3, weight, normalize,
g.GetNumberOfVertices(), g.GetMaxEdgeIndex()),
edge_floating_properties(),
vertex_floating_properties())
......@@ -150,9 +148,8 @@ void betweenness(GraphInterface& g, boost::any weight,
else
{
run_action<>()
(g, lambda::bind<void>
(get_betweenness(), lambda::_1, g.GetVertexIndex(), lambda::_2,
lambda::_3, normalize, g.GetNumberOfVertices()),
(g, bind<void>(get_betweenness(), _1, g.GetVertexIndex(), _2,
_3, normalize, g.GetNumberOfVertices()),
edge_floating_properties(),
vertex_floating_properties())
(edge_betweenness, vertex_betweenness);
......@@ -174,8 +171,8 @@ double central_point(GraphInterface& g,
{
double c = 0.0;
run_action<graph_tool::detail::never_reversed>()
(g, lambda::bind<void>(get_central_point_dominance(), lambda::_1,
lambda::_2, var(c)),
(g, bind<void>(get_central_point_dominance(), _1,
_2, ref(c)),
vertex_scalar_properties()) (vertex_betweenness);
return c;
}
......
......@@ -18,7 +18,6 @@
#include "graph_filtering.hh"
#include <boost/python.hpp>
#include <boost/lambda/bind.hpp>
#include "graph.hh"
#include "graph_selectors.hh"
......
......@@ -26,7 +26,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
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;
run_action<>()
(g, lambda::bind<void>(get_pagerank(),
lambda::_1, g.GetVertexIndex(), lambda::_2, d,
epslon, max_iter, lambda::var(iter)),
(g, bind<void>(get_pagerank(),
_1, g.GetVertexIndex(), _2, d,
epslon, max_iter, ref(iter)),
writable_vertex_scalar_properties())(rank);
return iter;
}
......
......@@ -27,7 +27,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
python::tuple global_clustering(GraphInterface& g)
......@@ -36,8 +35,7 @@ python::tuple global_clustering(GraphInterface& g)
bool directed = g.GetDirected();
g.SetDirected(false);
run_action<graph_tool::detail::never_directed>()
(g, lambda::bind<void>(get_global_clustering(), lambda::_1,
lambda::var(c), lambda::var(c_err)))();
(g, bind<void>(get_global_clustering(), _1, ref(c), ref(c_err)))();
g.SetDirected(directed);
return python::make_tuple(c, c_err);
}
......@@ -47,8 +45,7 @@ void local_clustering(GraphInterface& g, boost::any prop)
bool directed = g.GetDirected();
g.SetDirected(false);
run_action<graph_tool::detail::never_directed>()
(g, lambda::bind<void>(set_clustering_to_property(), lambda::_1,
lambda::_2),
(g, bind<void>(set_clustering_to_property(), _1, _2),
writable_vertex_scalar_properties())(prop);
g.SetDirected(directed);
}
......
......@@ -27,7 +27,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
template <class PropertySequence>
......@@ -37,8 +36,7 @@ struct prop_vector
{
boost::any prop_vec;
mpl::for_each<PropertySequence>
(lambda::bind<void>(get_prop_vector(), lambda::_1,
lambda::var(props), lambda::var(prop_vec),
(bind<void>(get_prop_vector(), _1, ref(props), ref(prop_vec),
size));
return prop_vec;
}
......@@ -94,9 +92,9 @@ void extended_clustering(GraphInterface& g, python::list props)
properties_vector;
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>
(g.GetVertexIndex()), lambda::_2),
(g.GetVertexIndex()), _2),
properties_vector()) (vprop);
}
......@@ -28,7 +28,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
struct null_copy
......@@ -89,8 +88,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
{
GraphInterface& sub =
python::extract<GraphInterface&>(subgraph_list[i]);
run_action<>()(sub, lambda::bind<void>(append_to_list(), lambda::_1,
lambda::var(list)))();
run_action<>()(sub, bind<void>(append_to_list(), _1,
ref(list)))();
}
}
catch (bad_any_cast&)
......@@ -115,10 +114,8 @@ void get_motifs(GraphInterface& g, size_t k, python::list subgraph_list,
sampler = sample_some(plist, rng);
run_action<>()
(g, lambda::bind<void>(get_all_motifs(), lambda::_1, k,
lambda::var(list), lambda::var(phist),
lambda::_2, plist[0], comp_iso,
fill_list, lambda::var(rng)),
(g, bind<void>(get_all_motifs(), _1, k, ref(list), ref(phist), _2,
plist[0], comp_iso, fill_list, ref(rng)),
mpl::vector<sample_all,sample_some>())(sampler);
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,
mpl::bool_<false>,mpl::bool_<true>,
mpl::bool_<true> >::type gviews;
run_action<gviews>()
(sub, lambda::bind<void>(retrieve_from_list(), lambda::_1,
lambda::var(list), lambda::var(done)))();
(sub, bind<void>(retrieve_from_list(), _1,
ref(list), ref(done)))();
if (!done)
{
sub.ReIndexEdges();
......
......@@ -20,7 +20,6 @@
#include "graph_selectors.hh"
#include "graph_properties.hh"
#include <boost/lambda/bind.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/python.hpp>
......@@ -28,7 +27,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
......@@ -39,11 +37,6 @@ void community_structure(GraphInterface& g, double gamma, string corr_name,
string history_file, boost::any weight,
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>,
GraphInterface::vertex_index_map_t,
mpl::bool_<false> >::type
......@@ -87,11 +80,6 @@ void community_structure(GraphInterface& g, double gamma, string corr_name,
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;
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> weight_map_t;
......@@ -104,7 +92,7 @@ double modularity(GraphInterface& g, boost::any weight, boost::any property)
bool directed = g.GetDirected();
g.SetDirected(false);
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())
(weight, property);
g.SetDirected(directed);
......
......@@ -20,7 +20,6 @@
#include "graph_selectors.hh"
#include "graph_properties.hh"
//#include <boost/lambda/bind.hpp>
#include <boost/bind.hpp>
#include <boost/bind/placeholders.hpp>
#include <boost/mpl/push_back.hpp>
......
......@@ -29,10 +29,9 @@ pair<double,double>
assortativity_coefficient(GraphInterface& gi,
GraphInterface::deg_t deg)
{
using namespace boost::lambda;
double a, a_err;
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));
return make_pair(a, a_err);
}
......@@ -41,10 +40,9 @@ pair<double,double>
scalar_assortativity_coefficient(GraphInterface& gi,
GraphInterface::deg_t deg)
{
using namespace boost::lambda;
double a, a_err;
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())
(degree_selector(deg));
return make_pair(a, a_err);
......
......@@ -17,7 +17,6 @@
#include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp>
#include "graph.hh"
......@@ -30,7 +29,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
// implementations spread across different compile units to minimize memory
......
......@@ -17,7 +17,6 @@
#include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp>
#include "graph.hh"
......@@ -30,7 +29,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight;
......
......@@ -17,8 +17,6 @@
#include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include "graph.hh"
#include "histogram.hh"
#include "graph_selectors.hh"
......@@ -28,7 +26,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
void graph_avg_corr_imp1(GraphInterface& g, python::object& avg,
......
......@@ -17,7 +17,6 @@
#include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp>
#include "graph.hh"
......@@ -31,7 +30,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
// implementations spread across different compile units to minimize memory
......
......@@ -32,7 +32,6 @@ namespace graph_tool
{
using namespace std;
using namespace boost;
using namespace boost::lambda;
// get degrees pairs from source and of neighbours
class GetNeighboursPairs
......
......@@ -17,7 +17,6 @@
#include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include <boost/python.hpp>
#include "graph.hh"
......@@ -29,7 +28,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight;
......
......@@ -17,8 +17,6 @@
#include "graph_filtering.hh"
#include <boost/lambda/bind.hpp>
#include "graph.hh"
#include "histogram.hh"
#include "graph_selectors.hh"
......@@ -28,7 +26,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
......
......@@ -23,7 +23,6 @@
using namespace std;
using namespace boost;
using namespace boost::lambda;
using namespace graph_tool;
typedef tr1::mt19937 rng_t;
......@@ -74,8 +73,7 @@ void generate_random_graph(GraphInterface& gi, size_t N,
if (uncorrelated)
{
run_action<graph_views>()
(gi, lambda::bind<void>(gen_random_graph<mpl::bool_<false> >(N),
lambda::_1,
(gi, bind<void>(gen_random_graph<mpl::bool_<false> >(N), _1,
PythonFuncWrap(deg_sample),
PythonFuncWrap(corr_deg_sample),
no_parallel, no_self_loops,
......@@ -84,8 +82,7 @@ void generate_random_graph(GraphInterface& gi, size_t N,
else
{
run_action<graph_views>()
(gi, lambda::bind<void>(gen_random_graph<mpl::bool_<true> >(N),
lambda::_1,
(gi, bind<void>(gen_random_graph<mpl::bool_<true> >(N), _1,
PythonFuncWrap(deg_sample),
PythonFuncWrap(corr_deg_sample),
no_parallel, no_self_loops,
......
......@@ -15,8 +15,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <boost/lambda/bind.hpp>
#include "graph.hh"
#include "graph_filtering.hh"
......@@ -24,7 +22,6 @@
using namespace graph_tool;
using namespace boost;
using namespace boost::lambda;
void predecessor_graph(GraphInterface& gi, GraphInterface& gpi,
boost::any pred_map)
......
......@@ -15,8 +15,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <boost/lambda/bind.hpp>
#include "graph.hh"
#include "graph_filtering.hh"
......@@ -25,9 +23,10 @@ typedef std::tr1::mt19937 rng_t;
#include "graph_rewiring.hh"
#include <boost/bind.hpp>
using namespace graph_tool;
using namespace boost;
using namespace boost::lambda;
void random_rewire(GraphInterface& gi, string strat, bool self_loops,
bool parallel_edges, size_t seed)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment