knn_complex: Generates a k-nearest neighbor complex from a distance...

Description Usage Arguments Value Examples

View source: R/knn_complex.R

Description

Takes a distance matrix, computes a k-nearest neighbor graph, and returns a clique complex that can be used by other functions in the RayleighSelection package.

Usage

1
knn_complex(dist, k, clique = TRUE)

Arguments

dist

a distance matrix.

k

nunber of nearest neighbors

clique

if set to FALSE the computation of 2-simplices is skipped.

Value

An object of the class simplicial. The class simplicial inherits from the class igraph.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(RayleighSelection)
# Load MNIST example dataset
data("mnist")

# Compute a distance matrix for a subset of the MNIST dataset
mnist_test <- mnist[,1:800]
mnist_test_distances <- (1.0 - cor(mnist_test))

# Compute nearest neighbor complex with k = 5
gg <- knn_complex(mnist_test, 5)

# Plot the skeleton of the nearest neighbor graph colored by the intensity of the 500th pixel
plot_skeleton(gg, k=as.numeric(mnist_test[500,]))

CamaraLab/RayleighSelection documentation built on Aug. 16, 2021, 12:01 p.m.