{"id":13411588,"url":"https://github.com/arl/go-rquad","last_synced_at":"2025-10-04T14:00:10.218Z","repository":{"id":57496806,"uuid":"68050916","full_name":"arl/go-rquad","owner":"arl","description":":pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go","archived":false,"fork":false,"pushed_at":"2022-06-22T22:06:28.000Z","size":4454,"stargazers_count":139,"open_issues_count":1,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-07T03:06:08.487Z","etag":null,"topics":["go","quadtree"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-12T21:46:37.000Z","updated_at":"2025-08-10T14:36:51.000Z","dependencies_parsed_at":"2022-08-29T20:31:41.510Z","dependency_job_id":null,"html_url":"https://github.com/arl/go-rquad","commit_stats":null,"previous_names":["aurelien-rainone/go-quadtrees","aurelien-rainone/go-rquad"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/arl/go-rquad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arl%2Fgo-rquad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arl%2Fgo-rquad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arl%2Fgo-rquad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arl%2Fgo-rquad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arl","download_url":"https://codeload.github.com/arl/go-rquad/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arl%2Fgo-rquad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274640910,"owners_count":25322843,"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-09-11T02:00:13.660Z","response_time":74,"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":["go","quadtree"],"created_at":"2024-07-30T20:01:14.763Z","updated_at":"2025-10-04T14:00:10.192Z","avatar_url":"https://github.com/arl.png","language":"Go","funding_links":[],"categories":["Generators","Uncategorized"],"sub_categories":["Miscellaneous Data Structures and Algorithms"],"readme":"# Region quadtrees in Go\n[![Build Status](https://travis-ci.org/arl/go-rquad.svg?branch=master)](https://travis-ci.org/arl/go-rquad) [![Coverage Status](https://coveralls.io/repos/github/arl/go-rquad/badge.svg?branch=master)](https://coveralls.io/github/arl/go-rquad?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/arl/go-rquad)](https://goreportcard.com/report/github.com/arl/go-rquad)\n[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/arl/go-rquad) \n\n**Region quadtrees and efficient neighbour finding techniques in Go**\n\n**Go-rquad** proposes various implementations of **region quadtrees**.\n\nA region quadtree is a special kind of quadtree that recursively\nsubdivides a 2 dimensional space into 4 smaller and generally equal\nrectangular regions, until the wanted quadtree resolution has been reached,\nor no further subdivisions can be performed.\n\nRegion quadtrees can be used for image processing; in this case a leaf node\nrepresents a rectangular region of an image in which all colors are equal or\nthe color difference is under a given threshold.\n\nRegion quadtrees may also be used to represent data fields with variable \nresolution. For example, the temperatures in an area may be stored as a\nquadtree where each leaf node stores the average temperature over the\nsubregion it represents.\n\nIn this package, quadtrees implement the [`imgscan.Scanner`](https://github.com/arl/imgtools/tree/master/imgscan) interface,\nthis provides a way to scan (i.e extract) the pixels in order to perform the subdivisions.\n\n## API Overview\n\n### `Node` interface\n```go\ntype Node interface {\n        Parent() Node\n        Child(Quadrant) Node\n        Bounds() image.Rectangle\n        Color() Color\n        Location() Quadrant\n}\n```\n\n### `Quadtree` interface\n\nA `Quadtree` represents a hierarchical collection of `Node`s, its API is\nsimple: access to the root Node and a way to iterate over all the leaves.\n\n```go\ntype Quadtree interface {\n        ForEachLeaf(Color, func(Node))\n        Root() Node\n}\n```\n\n### Functions\n\n`Locate` returns the leaf node of `q` that contains `pt`, or nil if `q` doesn't contain `pt`.\n```go\nfunc Locate(q Quadtree, pt image.Point) Node\n```\n\n`ForEachNeighbour` calls `fn` for each neighbour of `n`.\n```go\nfunc ForEachNeighbour(n Node, fn func(Node))\n```\n\n### Basic implementation: `BasicTree` and `basicNode`\n\n`BasicTree` is in many ways the standard implementation of `Quadtree`, it just does the job.\n\n### State of the art implementation: `CNTree` and `CNNode`\n\n`CNTree` or **Cardinal Neighbour Quadtree** implements state of the art techniques:\n - from any given leaf node, its neighbours (of any size) are accessed in constant time *0(1)*  as they implement the  *Cardinal Neighbour Quadtree* technique (cf Safwan Qasem 2015). The time complexity reduction is obtained through the addition of only four pointers per leaf node in the quadtree.\n - fast point location queries (locating which leaf node contains a specific point), thanks to the *binary branching method* (cf Frisken Perry 2002). This simple and efficient method is nonrecursive, table free, and reduces the number of comparisons with\npoor predictive behavior, that are otherwise required with the standard method.\n\n## Benchmarks\n\n![Quadtree creation benchmark](https://raw.githubusercontent.com/arl/go-rquad/readme-docs/Creation.png)\n\n![Neighbour finding benchmark](https://raw.githubusercontent.com/arl/go-rquad/readme-docs/Neighbours.png)\n\n![Point location benchmark](https://raw.githubusercontent.com/arl/go-rquad/readme-docs/PointLocation.png)\n\n## Research papers\n\n - Bottom-up neighour finding technique. cf Hanan Samet 1981,  \n*Neighbor Finding Techniques for Images Represented by Quadtrees*, [paper](https://raw.githubusercontent.com/arl/go-rquad/readme-docs/papers/a090240.pdf)\n\n - Cardinal Neighbor Quadtree. cf Safwan Qasem 2015,  \n*Cardinal Neighbor Quadtree: a New Quadtree-based Structure for Constant-Time Neighbor Finding*, [paper](https://raw.githubusercontent.com/arl/go-rquad/readme-docs/papers/qasem-2015-ijca-907501.pdf)\n\n - Fast point location using binary branching method. cf Frisken, Perry 2002  \n *Simple and Efficient Traversal Methods for Quadtrees and Octrees*, [paper](https://raw.githubusercontent.com/arl/go-rquad/readme-docs/papers/Simple.and.Efficient.Traversal.Methods.for.Quadtrees.TR2002-41.pdf)\n\n\n## License\n\ngo-rquad is open source software distributed in accordance with the MIT\nLicense, which says:\n\nCopyright (c) 2016 Aurélien Rainone\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farl%2Fgo-rquad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farl%2Fgo-rquad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farl%2Fgo-rquad/lists"}