Commit 07a7d556 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix bug in sfpd_layout() which causes positional artifacts

parent 28de6290
......@@ -99,21 +99,22 @@ struct do_propagate_pos
unordered_map<c_t, pos_t, boost::hash<c_t> >
cmap(num_vertices(*cg));
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
typename graph_traits<CoarseGraph>::vertex_iterator vi, vi_end;
for(tie(vi, vi_end) = vertices(*cg); vi != vi_end; ++vi)
{
typename graph_traits<Graph>::vertex_descriptor v = *vi;
typename graph_traits<CoarseGraph>::vertex_descriptor v = *vi;
cmap[cvmap[v]] = cpos[v];
pos[v].resize(2, 0);
}
for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
typename graph_traits<Graph>::vertex_iterator gvi, gvi_end;
for(tie(gvi, gvi_end) = vertices(g); gvi != gvi_end; ++gvi)
{
typename graph_traits<Graph>::vertex_descriptor v = *vi;
typename graph_traits<Graph>::vertex_descriptor v = *gvi;
pos[v] = cmap[vmap[v]];
if (delta > 0)
{
pos[v].resize(2, 0);
for (size_t j = 0; j < pos[v].size(); ++j)
pos[v][j] += noise(rng);
}
......
......@@ -224,7 +224,7 @@ struct get_sfdp_layout
vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
if (!pin[v])
if (pin[v] == 0)
vertices.push_back(v);
pos[v].resize(2, 0);
size_t s = group[v];
......@@ -261,9 +261,6 @@ struct get_sfdp_layout
val_t step = init_step;
size_t progress = 0;
vector<std::reference_wrapper<QuadTree<pos_t, vweight_t> > > Q;
Q.reserve(max_level * 2);
while (delta > epsilon * K && (max_iter == 0 || n_iter < max_iter))
{
delta = 0;
......@@ -285,22 +282,19 @@ struct get_sfdp_layout
std::shuffle(vertices.begin(), vertices.end(), rng);
pos_t diff(2, 0), pos_u(2, 0), ftot(2, 0), cm(2, 0);
size_t nmoves = 0;
N = vertices.size();
#pragma omp parallel for default(shared) private(i) \
firstprivate(Q, diff, pos_u, ftot, cm) \
reduction(+:E, delta, nmoves) schedule(static) if (N > 100)
for (i = 0; i < N; ++i)
{
typename graph_traits<Graph>::vertex_descriptor v =
vertex(vertices[i], g);
ftot[0] = ftot[1] = 0;
pos_t diff(2, 0), pos_u(2, 0), ftot(2, 0), cm(2, 0);
// global repulsive forces
Q.clear();
vector<std::reference_wrapper<QuadTree<pos_t, vweight_t> > > Q;
Q.push_back(std::ref(qt));
while (!Q.empty())
{
......
......@@ -375,6 +375,7 @@ def _propagate_pos(g, cg, c, cc, cpos, delta, mivs):
_prop("v", cg, cpos),
delta if mivs is None else 0,
_get_rng())
if mivs is not None:
g = g.base
u = GraphView(g, directed=False)
......
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