k-dimensional tree
Implementation of k-dimensional tree with no dependencies for multi purpose. Common uses are: search in multisemensional spaces (range searches and nearest neighbor searches).
Introduction
k-dimensional tree in data structure is a type of binary tree in which each leaf of the tree represents a point in a space of k dimensions.
This structure allows for very useful kinds of operations with an interesting computational cost. For instance, finding the post office closest to a certain point can be a hard task if the number of post offices is very large. A search for the nearest neighbor in a k-dimensional solves this problem with a computational cost of O (log n) in the average case.
Usage
$ npm i k-dimensional_tree
const KdTree Point Rect = ; // makes a KdTree for two dimensionsconst kdt = 2; kdt;kdt; console;console;console;
API
insert
Create point in tree
kdt;
contains
Check if point p exists in k-dimention tree
kdt;
size
Get numbet of points in k-dimentional tree
kdt;
isEmpty
Check if k-dimention tree is empty
kdt;
nodes
Get all points in k-dimentional tree
kdt;
nearest
Get nearest neighbor point of p point
kdt;
Range searchs
range
Query points inside rectangle
kdt;
pointsInRadius
Query all points inside radius from a p point
kdt