Description Usage Arguments Value Examples
View source: R/contrastMatrix.R
Build the contrast matrix of an KNN graph with n nodes
1 | build.M.nbr(K, nbr.K = NULL, D = NULL)
|
K |
number of neighbors for each node |
nbr.K |
nbr.K[i,] = the node indices ranked by proximity to node i (from the nearest to the farthest) |
D |
the distance matrix |
Returns the contrast matrix of a KNN graph with n nodes
1 2 3 4 5 6 7 8 9 10 | set.seed(121)
n <- 5 # number of nodes
X <- runif(n, -1, 1) # nodes are generated from U(-1, 1)
D <- as.matrix(dist(X)) # distance matrix for the nodes
nbr.K <- t(sortIndex(D)) # ranked indices based on distance
M1 <- build.M.nbr(K = 2, nbr.K = nbr.K[,-1])
M2 <- build.M.nbr(K = 2, D = D)
mean(M1 == M2) == 1 #returns TRUE
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.