rNN.dist: Compute r-Nearest Neighbours from a Distance Matrix
Description
Given a symmetric distance matrix, returns the indices of the \(r\) nearest neighbours for each observation.
Usage
rNN.dist(D, r)
Value
An \(n \times r\) integer matrix, where row \(i\) contains the indices of the r nearest neighbours of observation \(i\).
Arguments
D
An \(n \times n\) numeric (symmetric) distance matrix.
r
Integer indicating the number of nearest neighbours to extract for each observation.
Details
For each row \(i\) of D, the function orders the distances \(D[i, \cdot]\),
excludes the self-distance, and returns the indices of the first r smallest distances.
This provides the indices of the r nearest neighbours of observation \(i\).
References
Ghashti, J. S., Hare, W., and J. R. J. Thompson (2025). Variable-weighted adjacency constructions for fuzzy spectral clustering. Submitted.