Commit 1c478957 authored by Tiago Peixoto's avatar Tiago Peixoto

graph_blockmodel.hh: Small improvement to sample_block()

parent f8af5762
......@@ -1730,7 +1730,7 @@ public:
// attempt random block
size_t s;
std::bernoulli_distribution new_r(d);
if (new_r(rng) && (_candidate_blocks.size() - 1 < num_vertices(_g)))
if (d > 0 && new_r(rng) && (_candidate_blocks.size() - 1 < num_vertices(_g)))
{
if (_empty_blocks.empty())
add_block();
......@@ -1750,12 +1750,6 @@ public:
}
return s;
}
else
{
s = uniform_sample(_candidate_blocks.begin() + 1,
_candidate_blocks.end(),
rng);
}
if (!std::isinf(c) && !_neighbor_sampler.empty(v))
{
......@@ -1783,6 +1777,18 @@ public:
else
assert(size_t(_b[source(e, _g)]) == t);
}
else
{
s = uniform_sample(_candidate_blocks.begin() + 1,
_candidate_blocks.end(),
rng);
}
}
else
{
s = uniform_sample(_candidate_blocks.begin() + 1,
_candidate_blocks.end(),
rng);
}
return s;
......
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