Description Usage Arguments Value References Examples
For a graph with an adjacency matrix A, graph moment is defined as
ρ_m (A) = tr(A/n)^m
where n is the number of vertices and m is an order of the moment. nd.moments
computes
pairwise distances based on log of graph moments from m=1 to m=k.
1 2 3 4 5 6 | nd.moments(
A,
k = 3,
metric = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"),
out.dist = TRUE
)
|
A |
a list of length N containing (M\times M) adjacency matrices. |
k |
the integer order of moments. If k is too large, it may incur numerical overflow. |
metric |
type of distance measures for log-moment features. See |
out.dist |
a logical; |
a named list containing
an (N\times N) matrix or dist
object containing pairwise distance measures.
mukherjee_clustering_2017NetworkDistance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## load example data
data(graph20)
## compute distance based on different k's.
out3 <- nd.moments(graph20, k=3, out.dist=FALSE)
out5 <- nd.moments(graph20, k=5, out.dist=FALSE)
out7 <- nd.moments(graph20, k=7, out.dist=FALSE)
out9 <- nd.moments(graph20, k=9, out.dist=FALSE)
## visualize
opar = par(no.readonly=TRUE)
par(mfrow=c(2,2), pty="s")
image(out3$D[,20:1], col=gray(0:32/32), axes=FALSE, main="k=3")
image(out5$D[,20:1], col=gray(0:32/32), axes=FALSE, main="k=5")
image(out7$D[,20:1], col=gray(0:32/32), axes=FALSE, main="k=7")
image(out9$D[,20:1], col=gray(0:32/32), axes=FALSE, main="k=9")
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.