Commit d6aaa556 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Replace ConstantPropertyMap by UnityPropertyMap whenever appropriate

parent 27f82a7d
Pipeline #88 failed with stage
......@@ -33,12 +33,12 @@ long double eigenvector(GraphInterface& g, boost::any w, boost::any c,
throw ValueException("vertex property must be of floating point"
" value type");
typedef ConstantPropertyMap<int, GraphInterface::edge_t> weight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> weight_map_t;
typedef boost::mpl::push_back<writable_edge_scalar_properties, weight_map_t>::type
weight_props_t;
if(w.empty())
w = weight_map_t(1);
w = weight_map_t();
long double eig = 0;
run_action<>()
......
......@@ -59,12 +59,12 @@ long double hits(GraphInterface& g, boost::any w, boost::any x, boost::any y,
throw ValueException("vertex property must be of floating point"
" value type");
typedef ConstantPropertyMap<int, GraphInterface::edge_t> weight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> weight_map_t;
typedef boost::mpl::push_back<writable_edge_scalar_properties, weight_map_t>::type
weight_props_t;
if(w.empty())
w = weight_map_t(1);
w = weight_map_t();
long double eig = 0;
run_action<>()
......
......@@ -39,19 +39,19 @@ void katz(GraphInterface& g, boost::any w, boost::any c, boost::any beta,
throw ValueException("personalization vertex property must be of floating point"
" value type");
typedef ConstantPropertyMap<double, GraphInterface::edge_t> weight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> weight_map_t;
typedef boost::mpl::push_back<writable_edge_scalar_properties, weight_map_t>::type
weight_props_t;
if(w.empty())
w = weight_map_t(1.);
w = weight_map_t();
typedef ConstantPropertyMap<double, GraphInterface::vertex_t> beta_map_t;
typedef UnityPropertyMap<int,GraphInterface::vertex_t> beta_map_t;
typedef boost::mpl::push_back<vertex_floating_properties, beta_map_t>::type
beta_props_t;
if(beta.empty())
beta = beta_map_t(1.);
beta = beta_map_t();
run_action<>()(g, std::bind(get_katz(), std::placeholders::_1, g.get_vertex_index(),
std::placeholders::_2, std::placeholders::_3,
......
......@@ -44,7 +44,7 @@ size_t pagerank(GraphInterface& g, boost::any rank, boost::any pers,
if(pers.empty())
pers = pers_map_t(1.0 / g.get_num_vertices());
typedef ConstantPropertyMap<double, GraphInterface::edge_t> weight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> weight_map_t;
typedef boost::mpl::push_back<edge_scalar_properties, weight_map_t>::type
weight_props_t;
......@@ -52,7 +52,7 @@ size_t pagerank(GraphInterface& g, boost::any rank, boost::any pers,
throw ValueException("weight edge property must have a scalar value type");
if(weight.empty())
weight = weight_map_t(1.0);
weight = weight_map_t();
size_t iter;
run_action<>()
......
......@@ -79,12 +79,12 @@ double modularity(GraphInterface& g, boost::any weight, boost::any property)
{
double modularity = 0;
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> weight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> weight_map_t;
typedef boost::mpl::push_back<edge_scalar_properties, weight_map_t>::type
edge_props_t;
if(weight.empty())
weight = weight_map_t(1);
weight = weight_map_t();
run_action<graph_tool::detail::never_directed>()
(g, std::bind(get_modularity(), std::placeholders::_1, std::placeholders::_2,
......
......@@ -33,8 +33,8 @@ using namespace boost;
using namespace graph_tool;
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> no_eweight_map_t;
typedef ConstantPropertyMap<int32_t,GraphInterface::vertex_t> no_vweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> no_eweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::vertex_t> no_vweight_map_t;
typedef property_map_type::apply<int32_t,GraphInterface::edge_index_map_t>::type::unchecked_t ecount_map_t;
typedef property_map_type::apply<int32_t,GraphInterface::vertex_index_map_t>::type::unchecked_t vcount_map_t;
......@@ -97,7 +97,7 @@ void community_network(GraphInterface& gi, GraphInterface& cgi,
vweight_properties;
if (vweight.empty())
vweight = no_vweight_map_t(1);
vweight = no_vweight_map_t();
run_action<>()
(gi, std::bind(get_community_network_vertices_dispatch(),
......
......@@ -33,7 +33,7 @@ using namespace boost;
using namespace graph_tool;
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> no_eweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> no_eweight_map_t;
typedef property_map_type::apply<int32_t,GraphInterface::edge_index_map_t>::type ecount_map_t;
struct get_weighted_edge_property_dispatch
......@@ -68,7 +68,7 @@ void community_network_eavg(GraphInterface& gi, GraphInterface& cgi,
if (eweight.empty())
{
no_weight = true;
eweight = no_eweight_map_t(1);
eweight = no_eweight_map_t();
}
typedef boost::mpl::insert_range<writable_edge_scalar_properties,
......
......@@ -33,7 +33,7 @@ using namespace boost;
using namespace graph_tool;
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> no_eweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> no_eweight_map_t;
typedef property_map_type::apply<int32_t,GraphInterface::edge_index_map_t>::type ecount_map_t;
struct get_edge_sum_dispatch
......
......@@ -33,7 +33,7 @@ using namespace boost;
using namespace graph_tool;
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> no_eweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> no_eweight_map_t;
typedef property_map_type::apply<int32_t,GraphInterface::edge_index_map_t>::type::unchecked_t ecount_map_t;
struct get_community_network_edges_dispatch
......@@ -72,7 +72,7 @@ void community_network_edges(GraphInterface& gi, GraphInterface& cgi,
eweight_properties;
if (eweight.empty())
eweight = no_eweight_map_t(1);
eweight = no_eweight_map_t();
run_action<>()
(gi, std::bind(get_community_network_edges_dispatch(self_loops, parallel_edges),
......
......@@ -33,7 +33,7 @@ using namespace boost;
using namespace graph_tool;
typedef ConstantPropertyMap<int32_t,GraphInterface::vertex_t> no_vweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::vertex_t> no_vweight_map_t;
typedef property_map_type::apply<int32_t,GraphInterface::vertex_index_map_t>::type vcount_map_t;
......@@ -77,7 +77,7 @@ void community_network_vavg(GraphInterface& gi, GraphInterface& cgi,
if (vweight.empty())
{
no_weight = true;
vweight = no_vweight_map_t(1);
vweight = no_vweight_map_t();
}
typedef boost::mpl::insert_range<writable_vertex_scalar_properties,
......
......@@ -40,7 +40,7 @@ void graph_avg_corr_imp1(GraphInterface& g, boost::python::object& avg,
const vector<long double>& bins);
typedef ConstantPropertyMap<int,GraphInterface::edge_t> cweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> cweight_map_t;
boost::python::object
get_vertex_avg_correlation(GraphInterface& gi,
......@@ -61,7 +61,7 @@ get_vertex_avg_correlation(GraphInterface& gi,
weight_prop = wrapped_weight_t(weight, edge_scalar_properties());
}
else
weight_prop = cweight_map_t(1);
weight_prop = cweight_map_t();
try
{
......
......@@ -31,7 +31,7 @@ using namespace std;
using namespace boost;
using namespace graph_tool;
typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight;
typedef UnityPropertyMap<int,GraphInterface::edge_t> dummy_weight;
boost::python::object
get_vertex_avg_combined_correlation(GraphInterface& gi,
......
......@@ -41,7 +41,7 @@ void graph_correlations_imp1(GraphInterface& g, boost::python::object& hist,
const std::array<vector<long double>,2>& bins);
typedef ConstantPropertyMap<int,GraphInterface::edge_t> cweight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> cweight_map_t;
boost::python::object
get_vertex_correlation_histogram(GraphInterface& gi,
......@@ -67,7 +67,7 @@ get_vertex_correlation_histogram(GraphInterface& gi,
weight_prop = wrapped_weight_t(weight, edge_scalar_properties());
}
else
weight_prop = cweight_map_t(1);
weight_prop = cweight_map_t();
try
{
......
......@@ -30,7 +30,7 @@ using namespace std;
using namespace boost;
using namespace graph_tool;
typedef ConstantPropertyMap<int,GraphInterface::edge_t> dummy_weight;
typedef UnityPropertyMap<int,GraphInterface::edge_t> dummy_weight;
boost::python::object
get_vertex_combined_correlation_histogram(GraphInterface& gi,
......
......@@ -47,10 +47,10 @@ double min_cut(GraphInterface& gi, boost::any weight, boost::any part_map)
{
double mc = 0;
typedef ConstantPropertyMap<size_t,GraphInterface::edge_t> cweight_t;
typedef UnityPropertyMap<size_t,GraphInterface::edge_t> cweight_t;
if (weight.empty())
weight = cweight_t(1);
weight = cweight_t();
typedef boost::mpl::push_back<writable_edge_scalar_properties, cweight_t>::type
weight_maps;
......
......@@ -137,7 +137,7 @@ public:
typedef boost::property_map<multigraph_t, boost::vertex_index_t>::type vertex_index_map_t;
typedef boost::property_map<multigraph_t, boost::edge_index_t>::type edge_index_map_t;
typedef ConstantPropertyMap<size_t, boost::graph_property_tag> graph_index_map_t;
typedef ConstantPropertyMap<size_t,boost::graph_property_tag> graph_index_map_t;
// internal access
......
......@@ -617,18 +617,18 @@ public:
};
// the following is a property map which always returns one
template <class Key>
template <class Value, class Key>
class UnityPropertyMap
: public boost::put_get_helper<int, UnityPropertyMap<Key>>
: public boost::put_get_helper<Value, UnityPropertyMap<Value, Key>>
{
public:
typedef int value_type;
typedef Value value_type;
typedef value_type reference;
typedef Key key_type;
typedef boost::readable_property_map_tag category;
template <class K>
value_type operator[](const K&) const { return 1; }
value_type operator[](const K&) const { return value_type(1); }
};
......@@ -639,7 +639,7 @@ struct is_constant_property
typedef typename boost::property_traits<Property>::value_type value_type;
typedef typename std::conditional<std::is_same<Property, ConstantPropertyMap<value_type, key_type>>::value,
std::true_type,
typename std::is_same<Property, UnityPropertyMap<key_type>>::type>::type type;
typename std::is_same<Property, UnityPropertyMap<value_type, key_type>>::type>::type type;
};
......
......@@ -105,9 +105,9 @@ struct in_degreeS
return in_degree(v, g) * weight.c;
}
template <class Graph, class Vertex, class Key>
template <class Graph, class Vertex, class Key, class Value>
auto get_in_degree(Vertex v, const Graph& g, std::true_type,
const UnityPropertyMap<Key>&) const
const UnityPropertyMap<Value, Key>&) const
{
return in_degree(v, g);
}
......@@ -159,9 +159,9 @@ struct out_degreeS
return out_degree(v, g) * weight.c;
}
template <class Graph, class Vertex, class Key>
template <class Graph, class Vertex, class Key, class Value>
auto get_out_degree(Vertex v, const Graph& g,
const UnityPropertyMap<Key>&) const
const UnityPropertyMap<Value, Key>&) const
{
return out_degree(v, g);
}
......
......@@ -31,12 +31,12 @@ void arf_layout(GraphInterface& g, boost::any pos, boost::any weight, double d,
double a, double dt, size_t max_iter, double epsilon,
size_t dim)
{
typedef ConstantPropertyMap<int32_t,GraphInterface::edge_t> weight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> weight_map_t;
typedef boost::mpl::push_back<edge_scalar_properties, weight_map_t>::type
edge_props_t;
if(weight.empty())
weight = weight_map_t(1);
weight = weight_map_t();
run_action<graph_tool::detail::never_directed>()
(g, std::bind(get_arf_layout(), std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3, a, d, dt, epsilon, max_iter, dim),
......
......@@ -155,8 +155,6 @@ struct get_layout
cooling(cool).
force_pairs(all_force_pairs()));
}
};
......@@ -165,12 +163,12 @@ void fruchterman_reingold_layout(GraphInterface& g, boost::any pos,
bool square, double scale, bool grid,
double ti, double tf, size_t max_iter)
{
typedef ConstantPropertyMap<double,GraphInterface::edge_t> weight_map_t;
typedef UnityPropertyMap<int,GraphInterface::edge_t> weight_map_t;
typedef boost::mpl::push_back<edge_scalar_properties, weight_map_t>::type
edge_props_t;
if(weight.empty())
weight = weight_map_t(1.0);
weight = weight_map_t();
if (square)
run_action<graph_tool::detail::never_directed>()
(g,
......
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