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

FIX: updated addition of an object to the closest node

parent e5724f72
No related branches found
No related tags found
No related merge requests found
...@@ -127,14 +127,9 @@ class BuildTree { ...@@ -127,14 +127,9 @@ class BuildTree {
private void addObjectToClosestNode(int objectIndex) throws BucketStorageException { private void addObjectToClosestNode(int objectIndex) throws BucketStorageException {
LocalAbstractObject object = objectDistances.getObject(objectIndex); LocalAbstractObject object = objectDistances.getObject(objectIndex);
Function<Node, Float> getMinHullObjectDistance = node -> node.getHullObjects().stream() Map<Node, Double> nodeToObjectDistance = Arrays.stream(nodes)
.map(object::getDistance) .collect(Collectors.toMap(Function.identity(), node -> node.getDistance(object)));
.reduce(Float.MAX_VALUE, Math::min);
Map<Node, Float> nodeToObjectDistance = Arrays.stream(nodes)
.collect(Collectors.toMap(Function.identity(), getMinHullObjectDistance));
// Add object to the node with minimal distance to this object
Collections.min(nodeToObjectDistance.entrySet(), Map.Entry.comparingByValue()).getKey().addObject(object); Collections.min(nodeToObjectDistance.entrySet(), Map.Entry.comparingByValue()).getKey().addObject(object);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment