Skip to content
Snippets Groups Projects
Verified Commit 9531e93e authored by David Procházka's avatar David Procházka
Browse files

FIX: node-node distance type now owns the distance computation

parent 848ddb5f
No related branches found
No related tags found
No related merge requests found
package mhtree; package mhtree;
import messif.objects.LocalAbstractObject;
import java.util.function.BiFunction;
public enum NodeToNodeDistance { public enum NodeToNodeDistance {
NEAREST_HULL_OBJECTS, NEAREST_HULL_OBJECTS(Math::min, Float.MAX_VALUE),
FURTHEST_HULL_OBJECTS, FURTHEST_HULL_OBJECTS(Math::max, Float.MIN_VALUE);
private final BiFunction<Float, Float, Float> compareFunction;
private final float defaultValue;
NodeToNodeDistance(final BiFunction<Float, Float, Float> compareFunction, final float defaultValue) {
this.compareFunction = compareFunction;
this.defaultValue = defaultValue;
}
public float getDistance(Node node1, Node node2, BiFunction<LocalAbstractObject, LocalAbstractObject, Float> getDistance) {
float distance = defaultValue;
for (LocalAbstractObject firstHullObject : node1.getHullObjects())
for (LocalAbstractObject secondHullObject : node2.getHullObjects())
distance = compareFunction.apply(distance, getDistance.apply(firstHullObject, secondHullObject));
return distance;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment