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

ADD: best rank on both leaf and internal nodes

parent 236bfd55
No related branches found
No related tags found
No related merge requests found
...@@ -3,26 +3,37 @@ package mhtree; ...@@ -3,26 +3,37 @@ package mhtree;
import messif.objects.LocalAbstractObject; import messif.objects.LocalAbstractObject;
import static mhtree.ObjectToNodeDistance.NEAREST; import static mhtree.ObjectToNodeDistance.NEAREST;
import static mhtree.ObjectToNodeDistance.FURTHEST;
/** /**
* Represents the rank of a node in the priority queue in a query operation. * Represents the rank of a node in the priority queue
*/ */
public class ObjectToNodeDistanceRank implements Comparable<ObjectToNodeDistanceRank> { public class ObjectToNodeDistanceRank implements Comparable<ObjectToNodeDistanceRank> {
private final Node node; private final Node node;
private final double distance; private final double distance;
public ObjectToNodeDistanceRank(LocalAbstractObject object, Node node) { public ObjectToNodeDistanceRank(LocalAbstractObject object, Node node, int k) {
this.node = node; this.node = node;
if (node.isLeaf()) { if (node.isLeaf()) {
this.distance = NEAREST.getDistance(object, node); this.distance = NEAREST.getDistance(object, node);
} else { return;
}
if (k == 1) {
if (node.isCovered(object)) { if (node.isCovered(object)) {
this.distance = -node.getDistance(object); this.distance = -FURTHEST.getDistance(object, node);
} else { } else {
this.distance = node.getDistance(object); this.distance = FURTHEST.getDistance(object, node);
} }
return;
}
if (node.isCovered(object)) {
this.distance = -NEAREST.getDistance(object, node);
} else {
this.distance = NEAREST.getDistance(object, 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