/// <summary> /// Searches for the closest points in a hyper-sphere around the given center. /// </summary> /// <param name="center">The center of the hyper-sphere</param> /// <param name="radius">The radius of the hyper-sphere</param> /// <param name="neighboors">The number of neighbors to return.</param> /// <returns>The specified number of closest points in the hyper-sphere</returns> public List <TNode> NearestNeighborsRadial(TDimension[] center, double radius, int neighboors = -1) { var nearestNeighbors = new BoundedPriorityList <int, double>(neighboors == -1 ? this.Count : neighboors, false); var rect = HyperRect <TDimension> .Infinite(this.Dimensions, this.MaxValue, this.MinValue); this.SearchForNearestNeighbors(0, center, rect, 0, nearestNeighbors, radius); return(nearestNeighbors.ToResultSetRadial(this, neighboors)); }
/// <summary> /// Finds the nearest neighbors in the <see cref="KDTree{TDimension,TNode}"/> of the given <paramref name="point"/>. /// </summary> /// <param name="point">The point whose neighbors we search for.</param> /// <param name="neighbors">The number of neighbors to look for.</param> /// <returns>The</returns> public List <TNode> NearestNeighborsLinear(TDimension[] point, int neighbors) { var nearestNeighbors = new BoundedPriorityList <int, double>(neighbors, true); var rect = HyperRect <TDimension> .Infinite(this.Dimensions, this.MaxValue, this.MinValue); this.SearchForNearestNeighbors(0, point, rect, 0, nearestNeighbors, double.MaxValue); return(nearestNeighbors.ToResultSet(this)); }