Description Usage Arguments Details Value Author(s) References Examples
This function computes the distance between two adjacency matrix given as matrices or igraph objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 | netdist(x,...)
## S3 method for class 'matrix'
netdist(x, h, d = "HIM", ga = NULL, components=TRUE, ...)
## S3 method for class 'Matrix'
netdist(x, h, d = "HIM", ga = NULL, components=TRUE, ...)
## S3 method for class 'list'
netdist(x, d = "HIM", ga = NULL, components=TRUE, ...)
## S3 method for class 'igraph'
netdist(x, h, d = "HIM", ga = NULL, components=TRUE,...)
|
x |
Adjacency matrix, igraph object or list of adjacency matrices/igraph objects |
h |
Adjacency matrix or igraph object. Only when |
d |
|
ga |
|
components |
|
... |
Additional arguments to be passed to the downstream functions. Normally the argument passed through ... are processed by the functions which compute the distance. Not all parameters are used by all functions.
|
netdist
is a high level function which provide an interface to
different network distance methods. Distance can be computed for
weighted and unweighted networks either directed or undirected.
Each network must have the same number of nodes, otherwise no
computation will be performed and an errore message will be output.
Parallel computation is provided automatically through the
parallel package included by default from R 2.15, only for
methods "ipsen"
and "HIM"
.
The computation can be automatically parallelized on a multi-cpu
computer using the parameter n.cores
.
Input can be either an adjacency matrix, a graph object from igraph package or a list of adjacency matrix or graph objects.
If the 'weight' attribute is given within the graph
object it
will be used as edge weight, otherwise binary representation of the network will be considered.
In case edge weights are provided through the adjacency matrix, they
should be scaled between 0-1. If some of the weights are outside the
interval a scaling function is automatically applied.
The parameter ga
is used only in the Ipsen and
HIM distance. We suggest not to change it and use the automatic
computation of the parameter based on the number of nodes in the
network.
For components
set to FALSE
the distance between
the input networks is returned.
If components
is TRUE
and method is HIM
a named
vector with 3 values is returned, respectively the
Hamming(H
) distance, the Ipsen-Mikhailov
IM
distance and the HIM distance.
If a list
object is provided as input a distance matrix with
all the possible pairwise comparison is returned
M. Filosi, S. Riccadonna
G. Jurman, R. Visintainer, M. Filosi, S. Riccadonna, C. Furlanello
The HIM glocal metric and kernel for network comparison and classification arXiv 2013, arXiv:1201.2931v3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | a <- matrix(rnorm(200), nrow=20)
b <- matrix(rnorm(200), nrow=20)
aa <- mat2adj(a, method="cor", n.cores=1)
bb <- mat2adj(b, method="cor", n.cores=1)
dd <- netdist(aa,bb, d="HIM", n.cores=1)
print(dd)
## Use a different gamma parameter for HIM distance
dd <- netdist(aa,bb, d="HIM", ga=0.5, n.cores=1)
print(dd)
## The function can accept also list of adjacency matrices as input
alist <- list(aa,bb)
ddist <- netdist(alist, d="HIM", n.cores=1)
## Use of multiple cores
## Not run:
dd <- netdist(aa,bb,n.cores=4)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.