knn_dist: K nearest neighbors in a dissimilarity matrix

View source: R/knn_dist.R

knn_distR Documentation

K nearest neighbors in a dissimilarity matrix

Description

knn_dist searches for nearest neighbors in a dissimilarity matrix matrix.

Usage

knn_dist(D, K)

Arguments

D

Dissimilarity matrix of size (n,n), where n is the number of objects.

K

Number of neighbors

Details

This function is called by EkNNclus if argument x is not supplied. It is not optimized and cannot be used for very large D. If an attribute matrix x is supplied and D is the matrix of Euclidean distances, it is preferable to use function get.knn from package FNN.

Value

A list with two components:

nn.dist

An (n,K) matrix for the nearest neighbor dissimilarities.

nn.index

An (n,K) matrix for the nearest neighbor indices.

Author(s)

Thierry Denoeux.

See Also

get.knn, EkNNclus

Examples

data(butterfly)
n <- nrow(butterfly)
D<-as.matrix(dist(butterfly))
knn<-knn_dist(D,K=2)
knn$nn.dist
knn$nn.index

evclust documentation built on Nov. 9, 2023, 5:05 p.m.