Commit 410e8232 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

graph_blockmodel.hh: Fix bug with neighbour sampler

This fixes a bug with isolated nodes that contain only self-loops.
parent 34dbc181
......@@ -93,6 +93,7 @@ public:
}
size_t size() const { return _items.size(); }
bool empty() const { return _items.empty(); }
private:
......
......@@ -1261,9 +1261,10 @@ public:
// attempt random block
size_t s = uniform_sample(_candidate_blocks, rng);
if (!std::isinf(c) && total_degreeS()(v, _g) > 0)
auto& sampler = _neighbour_sampler[v];
if (!std::isinf(c) && !sampler.empty())
{
auto u = sample_neighbour(_neighbour_sampler[v], rng);
auto u = sample_neighbour(sampler, rng);
size_t t = _b[u];
double p_rand = 0;
if (c > 0)
......
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