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

Fix openmp bug in community_structure()

Call to random() must be protected by "omp critical".
parent 0ac9b1f6
......@@ -140,10 +140,15 @@ struct get_communities
size_t k = out_degree_no_loops(v, g);
double curr_e = gamma*Nnnks(k,s[v]) - ns[s[v]];
double new_e = gamma*Nnnks(k,new_s) - ns[new_s];
double new_e = gamma*Nnnks(k,new_s) - ns[new_s];
if (new_e < curr_e ||
random() < exp(-(new_e - curr_e)/T))
double r;
{
#pragma omp critical
r = random();
}
if (new_e < curr_e || r < exp(-(new_e - curr_e)/T))
{
temp_s[v] = new_s;
curr_e = new_e;
......
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