Commit 682d867b authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

average neighbour correlation must actually count neighbours twice, if double edges exist


git-svn-id: https://svn.forked.de/graph-tool/trunk@32 d4600afd-f417-0410-95de-beed9576f240
parent 53f38d38
...@@ -48,7 +48,6 @@ struct get_average_nearest_neighbours_correlation ...@@ -48,7 +48,6 @@ struct get_average_nearest_neighbours_correlation
void operator()(const Graph& g, AvgDeg& avg_deg) const void operator()(const Graph& g, AvgDeg& avg_deg) const
{ {
tr1::unordered_map<double,size_t> count; tr1::unordered_map<double,size_t> count;
tr1::unordered_set<typename graph_traits<Graph>::vertex_descriptor> neighbour_set;
typename graph_traits<Graph>::vertex_iterator v, v_begin, v_end; typename graph_traits<Graph>::vertex_iterator v, v_begin, v_end;
tie(v_begin,v_end) = vertices(g); tie(v_begin,v_end) = vertices(g);
...@@ -58,17 +57,12 @@ struct get_average_nearest_neighbours_correlation ...@@ -58,17 +57,12 @@ struct get_average_nearest_neighbours_correlation
tie(e_begin,e_end) = out_edges(*v,g); tie(e_begin,e_end) = out_edges(*v,g);
for(e = e_begin; e != e_end; ++e) for(e = e_begin; e != e_end; ++e)
{ {
if (neighbour_set.find(target(*e,g)) != neighbour_set.end())
continue;
else
neighbour_set.insert(target(*e,g));
typename AvgDeg::value_type::second_type::first_type deg = _neighbours_degree(target(*e,g),g); typename AvgDeg::value_type::second_type::first_type deg = _neighbours_degree(target(*e,g),g);
typename AvgDeg::key_type orig_deg = _origin_degree(*v,g); typename AvgDeg::key_type orig_deg = _origin_degree(*v,g);
avg_deg[orig_deg].first += deg; avg_deg[orig_deg].first += deg;
avg_deg[orig_deg].second += deg*deg; avg_deg[orig_deg].second += deg*deg;
count[orig_deg]++; count[orig_deg]++;
} }
neighbour_set.clear();
} }
for (typeof(avg_deg.begin()) iter = avg_deg.begin(); iter != avg_deg.end(); ++iter) for (typeof(avg_deg.begin()) iter = avg_deg.begin(); iter != avg_deg.end(); ++iter)
......
Supports Markdown
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