{"id":17272938,"url":"https://github.com/tomusdrw/kdtree","last_synced_at":"2025-08-22T15:04:04.372Z","repository":{"id":3766612,"uuid":"4843114","full_name":"tomusdrw/kdtree","owner":"tomusdrw","description":"K-d tree implementation for nearest neighbours searching.","archived":false,"fork":false,"pushed_at":"2016-01-29T08:17:49.000Z","size":182,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-31T00:46:45.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomusdrw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-30T14:46:59.000Z","updated_at":"2013-12-23T13:23:44.000Z","dependencies_parsed_at":"2022-08-28T23:22:29.270Z","dependency_job_id":null,"html_url":"https://github.com/tomusdrw/kdtree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tomusdrw/kdtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomusdrw%2Fkdtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomusdrw%2Fkdtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomusdrw%2Fkdtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomusdrw%2Fkdtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomusdrw","download_url":"https://codeload.github.com/tomusdrw/kdtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomusdrw%2Fkdtree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271657463,"owners_count":24797932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T08:49:49.052Z","updated_at":"2025-08-22T15:04:04.342Z","avatar_url":"https://github.com/tomusdrw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"JavaScript [k-d tree](http://en.wikipedia.org/wiki/K-d_tree) implementation.\n================================================\n\nSupports:\n * building balanced tree from predefined data\n * performing search for any given number of nearest neighbours\n\nSee [examples of usage](http://examples.blacksoft.eu/blacksoft.kdtree/examples):\n * [Nearest points on plane](http://examples.blacksoft.eu/blacksoft.kdtree/examples/NearestPoints.html)\n * [Classification (knn method)](http://examples.blacksoft.eu/blacksoft.kdtree/examples/Classification.html)\n\nSee [test suite](http://examples.blacksoft.eu/blacksoft.kdtree/tests/kdtree.html).\n\nYou can tune distance metric (default is euclid) and provide bucket size. Example:\n```javascript\nvar data = [\n\t[1, 2, 3, {additional: \"data\"}],\n\t[4, 5, 6, {additional: \"data2\"}]\n];\nvar k = data[0].length - 1;\nvar options = {\n\t/**\n\t * Defines bucket (terminal node) maximal size (default: 10)\n\t */\n\tbucketSize : 10,\n\t/**\n\t * Data dimension (default: data[0].length)\n\t */\n\tk : k,\n\t/**\n\t * Dissimilarity function (default: sqrt)\n\t */\n\tdissim : function(sum) {\n\t\treturn Math.sqrt(sum);\n\t},\n\t/**\n\t * Coordinate distance (default: (a-b)^2)\n\t */\n\tcoordinateDistance : function(a, b) {\n\t\tvar d = a - b;\n\t\treturn d * d;\n\t}\n};\nvar tree = kdtree.buildTree(data, options);\nvar noOfNeighboursToFind = 2;\nvar neighbours = tree.search([1, 2, 3], noOfNeighboursToFind);\n\nneighbours[0][k].additional === \"data\"; //true\nneighbours[1][k].additional === \"data2\"; //true\n```\n\nImplementation is based on paper:\nJH Friedman, JL Bentley, \"An algorithm for finding best matches in logarithmic expected time.\", 1977\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomusdrw%2Fkdtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomusdrw%2Fkdtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomusdrw%2Fkdtree/lists"}