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

Fix bug with parallel edges when deg_corr=True and dl=True in minimize_blockmodel_dl()

This closes #225
parent 65b8425e
...@@ -570,9 +570,10 @@ public: ...@@ -570,9 +570,10 @@ public:
return S_a - S_b; return S_a - S_b;
} }
template <class Graph, class OStats> template <class Graph, class OStats, class EWeight>
void move_vertex(size_t v, size_t r, size_t nr, bool deg_corr, OStats&, void move_vertex(size_t v, size_t r, size_t nr, bool deg_corr, OStats&,
Graph& g, size_t kin = 0, size_t kout = 0) Graph& g, EWeight& eweight, size_t kin = 0,
size_t kout = 0)
{ {
if (r == nr) if (r == nr)
return; return;
...@@ -589,8 +590,8 @@ public: ...@@ -589,8 +590,8 @@ public:
{ {
if (kin + kout == 0) if (kin + kout == 0)
{ {
kin = in_degreeS()(v, g); kin = in_degreeS()(v, g, eweight);
kout = out_degreeS()(v, g); kout = out_degreeS()(v, g, eweight);
} }
auto deg = make_pair(kin, kout); auto deg = make_pair(kin, kout);
auto iter = _hist[r].find(deg); auto iter = _hist[r].find(deg);
...@@ -1049,13 +1050,13 @@ void move_vertex(const Vec& vs, size_t nr, Eprop& mrs, Vprop& mrp, Vprop& mrm, ...@@ -1049,13 +1050,13 @@ void move_vertex(const Vec& vs, size_t nr, Eprop& mrs, Vprop& mrp, Vprop& mrm,
size_t kin = 0, kout = 0; size_t kin = 0, kout = 0;
for (auto v : vs) for (auto v : vs)
{ {
kin += in_degreeS()(v, g); kin += in_degreeS()(v, g, eweight);
kout += out_degreeS()(v, g); kout += out_degreeS()(v, g, eweight);
} }
if (partition_stats.is_enabled()) if (partition_stats.is_enabled())
partition_stats.move_vertex(vs[0], b[vs[0]], nr, deg_corr, overlap_stats, partition_stats.move_vertex(vs[0], b[vs[0]], nr, deg_corr, overlap_stats,
g, kin, kout); g, eweight, kin, kout);
for (auto v : vs) for (auto v : vs)
{ {
......
...@@ -1078,9 +1078,9 @@ struct overlap_partition_stats_t ...@@ -1078,9 +1078,9 @@ struct overlap_partition_stats_t
return S_a - S_b; return S_a - S_b;
} }
template <class Graph> template <class Graph, class EWeight>
void move_vertex(size_t v, size_t r, size_t nr, bool, void move_vertex(size_t v, size_t r, size_t nr, bool,
overlap_stats_t& overlap_stats, Graph& g, overlap_stats_t& overlap_stats, Graph& g, EWeight&,
size_t in_deg = 0, size_t out_deg = 0) size_t in_deg = 0, size_t out_deg = 0)
{ {
if (r == nr) if (r == nr)
......
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