Commit 8e851554 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Replace average by sum in condensation_graph()

parent 3c962eab
......@@ -280,19 +280,6 @@ struct get_vertex_community_property_sum
}
};
struct get_vertex_community_property_norm
{
template <class CommunityGraph, class VertexCountMap, class Vprop>
void operator()(const CommunityGraph& cg, VertexCountMap vertex_count,
Vprop cvprop) const
{
typename graph_traits<CommunityGraph>::vertex_iterator v, v_end;
for (tie(v, v_end) = vertices(cg); v != v_end; ++v)
cvprop[*v] /= vertex_count[*v];
}
};
struct get_weighted_edge_property
{
template <class Graph, class EdgeWeightMap, class Eprop>
......@@ -364,19 +351,6 @@ struct get_edge_community_property_sum
}
};
struct get_edge_community_property_norm
{
template <class CommunityGraph, class EdgeCountMap,
class Eprop>
void operator()(const CommunityGraph& cg, EdgeCountMap edge_count,
Eprop ceprop) const
{
typename graph_traits<CommunityGraph>::edge_iterator e, e_end;
for (tie(e, e_end) = edges(cg); e != e_end; ++e)
ceprop[*e] /= edge_count[*e];
}
};
} // graph_tool namespace
#endif // GRAPH_COMMUNITY_NETWORK_HH
......@@ -109,12 +109,5 @@ void community_network_eavg(GraphInterface& gi, GraphInterface& cgi,
ceprop, eprop, self_loops);
}
// norm summed values
run_action<graph_tool::detail::never_filtered>()
(cgi, std::bind(get_edge_community_property_norm(),
placeholders::_1, placeholders::_2,
placeholders::_3),
eweight_properties(), eprops_t())
(edge_count, ceprop);
}
}
......@@ -127,12 +127,5 @@ void community_network_vavg(GraphInterface& gi, GraphInterface& cgi,
writable_vertex_properties(), vprops_t())
(community_property, vprop);
}
// norm summed values
run_action<graph_tool::detail::never_filtered>()
(cgi, std::bind(get_vertex_community_property_norm(),
placeholders::_1, placeholders::_2, placeholders::_3),
vweight_properties(), vprops_t())
(vertex_count, cvprop);
}
}
......@@ -2453,10 +2453,10 @@ def condensation_graph(g, prop, vweight=None, eweight=None, avprops=None,
eweight : :class:`~graph_tool.PropertyMap` (optional, default: None)
Edge property map with the optional edge weights.
avprops : list of :class:`~graph_tool.PropertyMap` (optional, default: None)
If provided, the average value of each property map in this list for
If provided, the sum of each property map in this list for
each vertex in the condensed graph will be computed and returned.
aeprops : list of :class:`~graph_tool.PropertyMap` (optional, default: None)
If provided, the average value of each property map in this list for
If provided, the sum of each property map in this list for
each edge in the condensed graph will be computed and returned.
self_loops : ``bool`` (optional, default: ``False``)
If ``True``, self-loops due to intra-block edges are also included in
......@@ -2473,10 +2473,10 @@ def condensation_graph(g, prop, vweight=None, eweight=None, avprops=None,
ecount : :class:`~graph_tool.PropertyMap`
An edge property map with the inter-community edge count for each edge.
va : list of :class:`~graph_tool.PropertyMap`
A list of vertex property maps with average values of the properties
A list of vertex property maps with summed values of the properties
passed via the ``avprops`` parameter.
ea : list of :class:`~graph_tool.PropertyMap`
A list of edge property maps with average values of the properties
A list of edge property maps with summed values of the properties
passed via the ``avprops`` parameter.
See Also
......@@ -2566,7 +2566,7 @@ def condensation_graph(g, prop, vweight=None, eweight=None, avprops=None,
if p is g.vertex_index:
p = p.copy(value_type="int")
if "string" in p.value_type():
raise ValueError("Cannot compute average of string properties!")
raise ValueError("Cannot compute sum of string properties!")
temp = g.new_vertex_property(p.value_type())
cp = gp.new_vertex_property(p.value_type())
avp.append((_prop("v", g, p), _prop("v", g, temp), _prop("v", g, cp)))
......@@ -2580,7 +2580,7 @@ def condensation_graph(g, prop, vweight=None, eweight=None, avprops=None,
if p is g.edge_index:
p = p.copy(value_type="int")
if "string" in p.value_type():
raise ValueError("Cannot compute average of string properties!")
raise ValueError("Cannot compute sum of string properties!")
temp = g.new_edge_property(p.value_type())
cp = gp.new_edge_property(p.value_type())
aep.append((_prop("e", g, p), _prop("e", g, temp), _prop("e", g, cp)))
......
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