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

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

parent 4d7f9f81
No related branches found
No related tags found
No related merge requests found
package mhtree;
import messif.objects.LocalAbstractObject;
public enum ObjectToNodeDistance {
NEAREST_HULL_OBJECT,
FURTHEST_HULL_OBJECT,
AVERAGE_DISTANCE,
NEAREST_HULL_OBJECT {
@Override
public double getDistance(LocalAbstractObject object, Node node) {
return node.getHullObjects().stream()
.mapToDouble(object::getDistance)
.min()
.orElse(Double.MAX_VALUE);
}
},
FURTHEST_HULL_OBJECT {
@Override
public double getDistance(LocalAbstractObject object, Node node) {
return node.getHullObjects().stream()
.mapToDouble(object::getDistance)
.max()
.orElse(Double.MIN_VALUE);
}
},
AVERAGE_DISTANCE {
@Override
public double getDistance(LocalAbstractObject object, Node node) {
return node.getHullObjects().stream()
.mapToDouble(object::getDistance)
.sum() / node.getHullObjects().size();
}
};
public abstract double getDistance(LocalAbstractObject object, Node node);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment