* @return Weight sum
*/
protected double updateWeights(double[] weights, ArrayDBIDs ids, DBID latest, PrimitiveDoubleDistanceFunction<V> distF, Relation<V> rel) {
final V lv = rel.get(latest);
double weightsum = 0.0;
DBIDIter it = ids.iter();
for(int i = 0; i < weights.length; i++, it.advance()) {
DBID id = it.getDBID();
if(weights[i] > 0.0) {
double d = distF.doubleDistance(lv, rel.get(id));
weights[i] = Math.min(weights[i], d * d);
weightsum += weights[i];
}