# NOT RUN {
data(iris)
x <- iris[, -5]
# finding kNN and add the number of shared nearest neighbors.
k <- 5
nn <- sNN(x, k = k)
nn
# shared nearest neighbor distribution
table(as.vector(nn$shared))
# explore neighborhood of point 10
i <- 10
nn$shared[i,]
plot(nn, x)
# apply a threshold to create a sNN graph with edges
# if more than 3 neighbors are shared.
nn_3 <- sNN(nn, kt = 3)
plot(nn_3, x)
# get an adjacency list for the shared nearest neighbor graph
adjacencylist(nn_3)
# }
Run the code above in your browser using DataLab