https://github.com/downflux/go-kd Skip to content Sign up * Why GitHub? + Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Issues - + Integrations - + GitHub Sponsors - + Customer stories - * Team * Enterprise * Explore + Explore GitHub - + Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - + Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing + Plans - + Compare plans - + Contact Sales - + Education - [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} downflux / go-kd Public * Notifications * Star 20 * Fork 0 * Golang k-d tree implementation with duplicate coordinate support Apache-2.0 License 20 stars 0 forks Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show Loading {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default Loading View all tags 1 branch 8 tags Code Loading Latest commit @minkezhang minkezhang Fix rangesearch attempting to dereference nil pointers ... 1073983 Nov 15, 2021 Fix rangesearch attempting to dereference nil pointers 1073983 Git stats * 21 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows Add initial package declaration Nov 2, 2021 external/kyroy/kdtree Update NOTICE Nov 2, 2021 internal Fix rangesearch attempting to dereference nil pointers Nov 15, 2021 kd Fix K-D tree not supporting arbitrary dimensions Nov 15, 2021 point Update library to support k-dimensional trees Nov 15, 2021 .gitignore Initial commit Nov 2, 2021 LICENSE Initial commit Nov 2, 2021 NOTICE Update NOTICE Nov 2, 2021 README.md Fix K-D tree not supporting arbitrary dimensions Nov 15, 2021 go.mod Update library to support k-dimensional trees Nov 15, 2021 go.sum Update library to support k-dimensional trees Nov 15, 2021 View code go-kd Example README.md go-kd Golang k-d tree implementation with duplicate coordinate support See https://en.wikipedia.org/wiki/K-d_tree for more information. Example package main import ( "fmt" "github.com/downflux/go-geometry/nd/hypersphere" "github.com/downflux/go-geometry/nd/vector" "github.com/downflux/go-kd/kd" "github.com/downflux/go-kd/point" ) // P implements the point.P interface, which needs to provide a coordinate // vector function P(). type P struct { p vector.V tag string } func (p P) P() vector.V { return p.p } func main() { // N.B.: KD operations will return non-nil errors if the input vectors // are not a consistent length. p := *vector.New(1, 2, 3) origin := *vector.New(0, 0, 0) t, _ := kd.New([]point.P{ P{p: p, tag: "A"}, P{p: p, tag: "B"}, }) fmt.Println("KNN search") ns, _ := kd.KNN(t, origin, 2) for _, p := range ns { fmt.Println(p) } // Remove deletes the first data point at the given input coordinate and // matches the input check function. t.Remove(p, func(p point.P) bool { return p.(P).tag == "B" }) // RadialFilter returns all points within the circle range and match the // input filter function. fmt.Println("radial search") ns, _ = kd.RadialFilter(t, *hypersphere.New(origin, 5), func(p point.P) bool { return true }) for _, p := range ns { fmt.Println(p) } } About Golang k-d tree implementation with duplicate coordinate support Resources Readme License Apache-2.0 License Releases 7 v0.3.2 Latest Nov 15, 2021 + 6 releases Packages 0 No packages published Languages * Go 100.0% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.