@Override public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) { this.searchN = searchN; this.neighbors = results; _findClosest(target); }
@Override public KdTree.Node findNeighbor(P target) { bestNode = null; _findClosest(target); return bestNode; }
/** * Finds the node which is closest to 'target' * * @param target A point * @return Closest node or null if none is within the minimum distance. */ @Override public KdTree.Node findNeighbor(P target) { if( tree.root == null ) return null; this.target = target; this.closest = null; this.bestDistanceSq = maxDistanceSq; stepClosest(tree.root); return closest; }
@Override public boolean findNearest(P point, double maxDistance, NnData<P> result) { if( maxDistance < 0 ) search1.setMaxDistance(Double.MAX_VALUE); else search1.setMaxDistance(maxDistance); KdTree.Node found = search1.findNeighbor(point); if( found == null ) return false; result.point = (P)found.point; result.index = found.index; result.distance = search1.getDistance(); return true; }
public KdForestBbfSearch(int numberOfTrees, int maxNodesSearched, KdTreeDistance<P> distance , AxisSplitter<P> splitter) { this.forest = new KdTree[ numberOfTrees ]; this.splitter = splitter; this.search1 = new KdTreeSearch1Bbf<>(distance,maxNodesSearched); this.searchN = new KdTreeSearchNBbf<>(distance,maxNodesSearched); this.constructor = new KdTreeConstructor<P>(memory,splitter); }
public KdTreeNearestNeighbor( KdTreeDistance<P> distance ) { this( new KdTreeSearch1Standard<>(distance), new KdTreeSearchNStandard<>(distance), new AxisSplitterMedian<>(distance)); }
@Override public void setPoints(List<P> points , boolean trackIndicies ) { if( forest[0] != null ) { for( int i = 0; i < forest.length; i++ ) memory.recycleGraph(forest[i]); } for( int i = 0; i < forest.length; i++ ) forest[i] = constructor.construct(points,trackIndicies); search1.setTrees(forest); searchN.setTrees(forest); }
/** * Provide an insufficient number of steps to produce an optimal solution and see if it produces the expected * result */ @Test public void checkMaxNodes() { KdTree tree = StandardKdTreeSearch1Tests.createTreeA(); BBF alg = new BBF(0,2); alg.setTree(tree); KdTree.Node found = alg.findClosest(new double[]{12,2}); // The first search from the root node is not counted. In that search it will traverse down to a leaf assertTrue(found==tree.root.left.right); }
@Override public KdTreeSearchN<double[]> createAlg() { return new KdTreeSearchNStandard<>(new KdTreeEuclideanSq_F64(N)); } }
@Override public KdTreeSearch1<double[]> createAlg() { return new KdTreeSearch1Standard<>(new KdTreeEuclideanSq_F64(N)); } }
@Override public KdTreeSearch1<double[]> createAlg() { // specify so many max nodes that it will be optimal return new KdTreeSearch1Bbf<>(new KdTreeEuclideanSq_F64(N),10000); } }
@Override public KdTreeSearchN<double[]> createAlg() { // specify so many max nodes that it will be optimal return new KdTreeSearchNBbf<>(new KdTreeEuclideanSq_F64(2),10000); }
public KdTree.Node findClosest(double[] target) { bestNode = null; _findClosest(target); return bestNode; }
@Override public boolean findNearest(P point, double maxDistance, NnData<P> result) { if( maxDistance < 0 ) search1.setMaxDistance(Double.MAX_VALUE); else search1.setMaxDistance(maxDistance); KdTree.Node found = search1.findNeighbor(point); if( found == null ) return false; result.point = (P)found.point; result.index = found.index; result.distance = search1.getDistance(); return true; }
public KdForestBbfSearch(int numberOfTrees, int maxNodesSearched, KdTreeDistance<P> distance , AxisSplitter<P> splitter) { this.forest = new KdTree[ numberOfTrees ]; this.splitter = splitter; this.search1 = new KdTreeSearch1Bbf<>(distance,maxNodesSearched); this.searchN = new KdTreeSearchNBbf<>(distance,maxNodesSearched); this.constructor = new KdTreeConstructor<P>(memory,splitter); }
public KdTreeNearestNeighbor( KdTreeDistance<P> distance ) { this( new KdTreeSearch1Standard<>(distance), new KdTreeSearchNStandard<>(distance), new AxisSplitterMedian<>(distance)); }
@Override public void setPoints(List<P> points , boolean trackIndicies ) { if( forest[0] != null ) { for( int i = 0; i < forest.length; i++ ) memory.recycleGraph(forest[i]); } for( int i = 0; i < forest.length; i++ ) forest[i] = constructor.construct(points,trackIndicies); search1.setTrees(forest); searchN.setTrees(forest); }
@Override public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) { this.searchN = searchN; this.neighbors = results; _findClosest(target); }
@Override public KdTree.Node findNeighbor(P target) { bestNode = null; _findClosest(target); return bestNode; }
/** * Finds the node which is closest to 'target' * * @param target A point * @return Closest node or null if none is within the minimum distance. */ @Override public KdTree.Node findNeighbor(P target) { if( tree.root == null ) return null; this.target = target; this.closest = null; this.bestDistanceSq = maxDistanceSq; stepClosest(tree.root); return closest; }