final double[] distancesBefore = new double[netSize];
int count = 0;
for (Neuron n : net) {
distancesBefore[count++] = dist.compute(n.getFeatures(), features);
}
final Neuron bestBefore = MapUtils.findBest(features, net, dist);
// Initial distance from the best match is larger than zero.
Assert.assertTrue(dist.compute(bestBefore.getFeatures(), features) >= 0.2);
update.update(net, features);
final double[] distancesAfter = new double[netSize];
count = 0;
for (Neuron n : net) {
distancesAfter[count++] = dist.compute(n.getFeatures(), features);
}
final Neuron bestAfter = MapUtils.findBest(features, net, dist);
Assert.assertEquals(bestBefore, bestAfter);
// Distance is now zero.
Assert.assertEquals(0, dist.compute(bestAfter.getFeatures(), features), 0d);
for (int i = 0; i < netSize; i++) {
// All distances have decreased.
Assert.assertTrue(distancesAfter[i] < distancesBefore[i]);
}