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

Fix bug with BlockState.merge_sweep()

parent 42c81a3d
......@@ -410,10 +410,9 @@ public:
}
}
void remove_vertices(python::object ovs)
template <class Vec>
void remove_vertices(Vec& vs)
{
multi_array_ref<uint64_t, 1> vs = get_array<uint64_t, 1>(ovs);
switch (_rec_type)
{
case weight_type::POSITIVE: // positive weights
......@@ -440,6 +439,12 @@ public:
}
}
void remove_vertices(python::object ovs)
{
multi_array_ref<uint64_t, 1> vs = get_array<uint64_t, 1>(ovs);
remove_vertices(vs);
}
template <class BEdge, class Efilt>
void add_vertex(size_t v, size_t r, BEdge&& bedge, Efilt&& efilt)
{
......@@ -539,10 +544,9 @@ public:
}
}
void add_vertices(python::object ovs, python::object ors)
template <class Vs, class Rs>
void add_vertices(Vs& vs, Rs& rs)
{
multi_array_ref<uint64_t, 1> vs = get_array<uint64_t, 1>(ovs);
multi_array_ref<uint64_t, 1> rs = get_array<uint64_t, 1>(ors);
if (vs.size() != rs.size())
throw ValueException("vertex and group lists do not have the same size");
switch (_rec_type)
......@@ -572,9 +576,19 @@ public:
}
}
bool allow_move(size_t r, size_t nr)
void add_vertices(python::object ovs, python::object ors)
{
return ((_bclabel[r] == _bclabel[nr]) || (_wr[nr] == 0));
multi_array_ref<uint64_t, 1> vs = get_array<uint64_t, 1>(ovs);
multi_array_ref<uint64_t, 1> rs = get_array<uint64_t, 1>(ors);
add_vertices(vs, rs);
}
bool allow_move(size_t r, size_t nr, bool allow_empty = true)
{
if (allow_empty)
return ((_bclabel[r] == _bclabel[nr]) || (_wr[nr] == 0));
else
return ((_bclabel[r] == _bclabel[nr]));
}
// move a vertex from its current block to block nr
......
......@@ -100,18 +100,19 @@ struct Merge
template <class RNG>
size_t move_proposal(size_t v, bool random, RNG& rng)
{
size_t r = _state._b[v];
size_t s;
if (!random)
{
size_t r = _state.random_neighbour(v, rng);
s = _state.random_neighbour(r, rng);
size_t t = _state.random_neighbour(v, rng);
s = _state.random_neighbour(t, rng);
}
else
{
s = uniform_sample(_available, rng);
}
if (s == v || !_state.allow_move(v, s))
if (s == v || !_state.allow_move(r, s, false))
return _null_move;
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