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

graph_blockmodel.hh: Small improvement to sample_block()

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