Nearest Neighbor Descent Method for Approximate Nearest Neighbors
Overview
The Nearest Neighbor Descent method for finding approximate nearest neighbors by Dong and co-workers (2010) doi:10.1145/1963405.1963487. Based on the 'Python' package 'PyNNDescent' https://github.com/lmcinnes/pynndescent.
New features
- Add
haversinemetric for 2D latitude/longitude data in radians. This is
one of the metrics that was in PyNNDescent but I neglected to add to
rnndescent for its initial release. Thank you to
Josiah Parry whose request nudged me to fill
this gap (<https://github.com/jlmelville/rnndescent/issues/17>).
Bug fixes and minor improvements
- Much improved input validation.
- Non-
dgCMatrixsparseMatrixinputs, such asdgRMatrixanddgTMatrixare
now normalized to dgCMatrix on input. Other matrices fail with a clearer error.
- Fix for
prepare_search_graph()sometimes over-pruning beyondmax_degree. - Fix explicit-margin RP-tree builds for
metric = "dice"and"hamming"to
Show all changes in 0.2.0Hide the rest of the changes in 0.2.0
use angular split geometry.
- Fix for
rpf_build(obs = "C")where defaultn_treesused the number of
features not the number of observations.
- Fix
nnd_knn()andgraph_knn_query()sometimes failing to completely randomly fill
the initial search graph when needed.
- Fix for
prepare_search_graph(prune_reverse = TRUE)not pruning reverse edges
when diversify_prob = 0.
- Fix for edge case when
max_search_fractionwould only result in one
calculation, but this distance was never used.
- Fixes for
k_occur()when using graphs with missing data and sparse graphs
with anti-hubs.
- Verbose query summaries now report the correct minimum and average number of
distance calculations.
- Minor parallel execution robustness improvements: errors propagate back to R
and some worker launches are avoided with small workloads.
- Minor C++ portability improvements for CRAN builds and high-dimensional
logical metrics.
- Some C++ changes to avoid a (probably false positive) gcc16 compiler warning
found by CRAN checks.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-05-31
- WARNING12 OK, 1 WARNING2026-05-13
- OK12 OK2026-04-25
Show 3 earlier changesHide 3 earlier changes
- NOTE12 OK, 2 NOTE2026-04-22
- ERROR11 OK, 2 NOTE, 1 ERROR2026-04-18
- NOTE12 OK, 2 NOTE2026-03-10
Documentation
The repository also keeps web-only articles.
- Help pages
- 18 (1 internal)includes a package overview page
- Examples that run
- 100%17 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 61%
- rnndescent HTML
- Brute Force Search HTML
- Hubness
- Metrics HTML
- Nearest Neighbor Descent HTML
- Querying Data
- Random Partition Forests HTML
Downloads
Repository
- PRs merged (all time)
- 96%
- Median days to close, 50 most recently updated closed issues
- 168
- Median days to close, 50 most recently updated closed PRs
- 1
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
12 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/jlmelville/rnndescent on 2026-10-11.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-10 · The repository has a site deploy workflow
pkgdown site last built 2026-10-10
Show all practicesHide 2 practices
Dependencies
Installing rnndescent adds 4 packages (3 with compiled code, 16 MB of source tarballs). Heaviest: BH 14 MB, Rcpp 1.8 MB, dqrng 261 KB.
Code & Tests
People & History
Package metadata
- First published
- 2023-11-27
- Total releases
- 7 / 3 yrs
- License
- GPL (>= 3) OSI
- Download size
- 349 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("rnndescent")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-19, which the citation names so these numbers can be found later. More on citing and the projects behind them.