There is a Javascript library kd-tree-javascript that is used to construct kdtree and perform queries like nearest neighbour search and range search.
Link to the library : https://github.com/ubilabs/kd-tree-javascript
const distance = (a: { x: number; y: number }, b: { x: number; y: number }) => {
return Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2);
};
let's say we have 2D points. the tree is constructed as:
const createdTree = new kdTree(points, distance, ['x', 'y']);
Now my question is how do we define leaf size while creating this tree? just like in python library, there is a parameter for setting leaf size.
class scipy.spatial.KDTree(data, leafsize=10, compact_nodes=True, copy_data=False, balanced_tree=True, boxsize=None)
How do I specify leaf size?