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

Fix segfault in sfdp_layout()

parent 58b73413
...@@ -97,33 +97,24 @@ struct do_propagate_pos ...@@ -97,33 +97,24 @@ struct do_propagate_pos
uniform_real_distribution<val_t> noise(-delta, delta); uniform_real_distribution<val_t> noise(-delta, delta);
unordered_map<c_t, pos_t, boost::hash<c_t> > unordered_map<c_t, pos_t, boost::hash<c_t> >
cmap(num_vertices(*cg)); cmap(num_vertices(*cg));
int i, N = num_vertices(*cg);
#pragma omp parallel for default(shared) private(i) typename graph_traits<Graph>::vertex_iterator vi, vi_end;
for (i = 0; i < N; ++i) for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
{ {
typename graph_traits<CoarseGraph>::vertex_descriptor v = typename graph_traits<Graph>::vertex_descriptor v = *vi;
vertex(i, *cg);
if (v == graph_traits<CoarseGraph>::null_vertex())
continue;
cmap[cvmap[v]] = cpos[v]; cmap[cvmap[v]] = cpos[v];
pos[v].resize(2, 0);
} }
N = num_vertices(g); for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
#pragma omp parallel for default(shared) private(i)
for (i = 0; i < N; ++i)
{ {
typename graph_traits<Graph>::vertex_descriptor v = typename graph_traits<Graph>::vertex_descriptor v = *vi;
vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
pos[v] = cmap[vmap[v]]; pos[v] = cmap[vmap[v]];
if (delta > 0)
{ {
if (delta > 0) for (size_t j = 0; j < pos[v].size(); ++j)
{ pos[v][j] += noise(rng);
#pragma omp critical
for (size_t j = 0; j < pos[v].size(); ++j)
pos[v][j] += noise(rng);
}
} }
} }
} }
...@@ -169,14 +160,10 @@ struct do_propagate_pos_mivs ...@@ -169,14 +160,10 @@ struct do_propagate_pos_mivs
uniform_real_distribution<val_t> noise(-delta, delta); uniform_real_distribution<val_t> noise(-delta, delta);
int i, N = num_vertices(g); typename graph_traits<Graph>::vertex_iterator vi, vi_end;
#pragma omp parallel for default(shared) private(i) for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
for (i = 0; i < N; ++i)
{ {
typename graph_traits<Graph>::vertex_descriptor v = typename graph_traits<Graph>::vertex_descriptor v = *vi;
vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
if (mivs[v]) if (mivs[v])
continue; continue;
pos[v].resize(2); pos[v].resize(2);
...@@ -187,6 +174,7 @@ struct do_propagate_pos_mivs ...@@ -187,6 +174,7 @@ struct do_propagate_pos_mivs
{ {
if (!mivs[*a]) if (!mivs[*a])
continue; continue;
pos[*a].resize(2, 0);
for (size_t j = 0; j < pos[v].size(); ++j) for (size_t j = 0; j < pos[v].size(); ++j)
pos[v][j] += pos[*a][j]; pos[v][j] += pos[*a][j];
++count; ++count;
...@@ -200,7 +188,6 @@ struct do_propagate_pos_mivs ...@@ -200,7 +188,6 @@ struct do_propagate_pos_mivs
{ {
if (delta > 0) if (delta > 0)
{ {
#pragma omp critical
for (size_t j = 0; j < pos[v].size(); ++j) for (size_t j = 0; j < pos[v].size(); ++j)
pos[v][j] += noise(rng); pos[v][j] += noise(rng);
} }
......
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