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

ADD: object to node distance javadoc

parent 326edb28
No related branches found
No related tags found
No related merge requests found
......@@ -2,33 +2,60 @@ package mhtree;
import messif.objects.LocalAbstractObject;
/**
* Specifies possible distances between an object and a node.
*/
public enum ObjectToNodeDistance {
NEAREST_HULL_OBJECT {
/**
* Average distance between {@code object} and every hull object in {@code node}.
*/
AVERAGE {
@Override
public double getDistance(LocalAbstractObject object, Node node) {
return node.getHullObjects().stream()
return node
.getHullObjects()
.stream()
.mapToDouble(object::getDistance)
.min()
.orElse(Double.MAX_VALUE);
.sum() / node.getHullObjects().size();
}
},
FURTHEST_HULL_OBJECT {
/**
* Distance between {@code object} and {@code node}'s furthest hull object.
*/
FURTHEST {
@Override
public double getDistance(LocalAbstractObject object, Node node) {
return node.getHullObjects().stream()
return node
.getHullObjects()
.stream()
.mapToDouble(object::getDistance)
.max()
.orElse(Double.MIN_VALUE);
}
},
AVERAGE_DISTANCE {
/**
* Distance between {@code object} and {@code node}'s nearest hull object.
*/
NEAREST {
@Override
public double getDistance(LocalAbstractObject object, Node node) {
return node.getHullObjects().stream()
return node
.getHullObjects()
.stream()
.mapToDouble(object::getDistance)
.sum() / node.getHullObjects().size();
.min()
.orElse(Double.MAX_VALUE);
}
};
/**
* Returns the distance between {@code object} and {@code node}.
*
* @param object an object
* @param node a node
* @return the distance between {@code object} and {@code node}
*/
public abstract double getDistance(LocalAbstractObject object, Node node);
}
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