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
...@@ -142,8 +142,13 @@ struct get_communities ...@@ -142,8 +142,13 @@ struct get_communities
double curr_e = gamma*Nnnks(k,s[v]) - ns[s[v]]; 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 || double r;
random() < exp(-(new_e - curr_e)/T)) {
#pragma omp critical
r = random();
}
if (new_e < curr_e || r < exp(-(new_e - curr_e)/T))
{ {
temp_s[v] = new_s; temp_s[v] = new_s;
curr_e = new_e; curr_e = new_e;
......
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