Commit 3f177dfc authored by Tiago Peixoto's avatar Tiago Peixoto

generate_knn(): fix problem with equal distances

parent 31038455
......@@ -112,11 +112,15 @@ void gen_knn(Graph& g, Dist&& d, size_t k, double r, double epsilon,
auto iter = Bv.lower_bound({w, l});
if (iter != Bv.end() && get<0>(*iter) != w)
{
size_t n = Bv.size();
Bv.insert(iter, {w, l});
iter = Bv.end();
--iter;
Bv.erase(iter);
++c;
if (Bv.size() > n)
{
iter = Bv.end();
--iter;
Bv.erase(iter);
++c;
}
}
}
}
......
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