View source: R/buildFromAdjacency.R
buildFromAdjacency | R Documentation |
Construct a kNN-graph from an input adjacency matrix - either binary or distances between NNs.
x |
An n X n |
k |
(optional) Scalar value that represents the number of nearest neighbours in the original graph. This
can also be inferred directly from the adjacency matrix |
is.binary |
Logical scalar indicating if the input matrix is binary or not. |
This function will take a matrix as input and construct the kNN graph that it describes. If the matrix is not symmetric then the graph is assumed to be directed, whereas if the matrix is not binary, i.e. all 0's and 1's then the input values are taken to be distances between graph vertices; 0 values are assumed to represent a lack of edge between vertices.
A Milo
with the graph slot populated.
Mike Morgan
r <- 1000
c <- 1000
k <- 35
m <- floor(matrix(runif(r*c), r, c))
for(i in seq_along(1:r)){
m[i, sample(1:c, size=k)] <- 1
}
milo <- buildFromAdjacency(m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.