nd_moments: Log Moments Distance

Description Usage Arguments Value References Examples

Description

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.

Usage

1
2
3
4
5
6
nd.moments(
  A,
  k = 3,
  metric = c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"),
  out.dist = TRUE
)

Arguments

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 dist for more details.

out.dist

a logical; TRUE for computed distance matrix as a dist object.

Value

a named list containing

D

an (N\times N) matrix or dist object containing pairwise distance measures.

References

\insertRef

mukherjee_clustering_2017NetworkDistance

Examples

 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)

NetworkDistance documentation built on Aug. 21, 2021, 5:07 p.m.