View source: R/assortativity.R
assortcoef | R Documentation |
Compute the assortativity coefficient(s) for a network.
assortcoef(netwk, edgelist, edgeweight, adj, directed, f1, f2)
netwk |
A |
edgelist |
A two-column matrix representing edges. |
edgeweight |
A numeric vector of edge weights with the same length as
the number of rows in edgelist. If |
adj |
The adjacency matrix of a network. |
directed |
Logical. Indicates whether the edges in |
f1 |
A vector representing the first feature of existing nodes. The
number of nodes should be equal to the length of both |
f2 |
A vector representing the second feature of existing nodes. Defined
for directed networks. If |
Assortativity coefficient for undirected networks, or a list of four assortativity coefficients for directed networks.
When the adjacency matrix is binary (i.e., directed but unweighted
networks), assortcoef
returns the assortativity coefficient proposed
in Foster et al. (2010).
Foster, J.G., Foster, D.V., Grassberger, P. and Paczuski, M. (2010). Edge direction and the structure of networks. Proceedings of the National Academy of Sciences of the United States, 107(24), 10815–10820.
Yuan, Y. Zhang, P. and Yan, J. (2021). Assortativity coefficients for weighted and directed networks. Journal of Complex Networks, 9(2), cnab017.
set.seed(123)
control <- rpa_control_edgeweight(
sampler = function(n) rgamma(n, shape = 5, scale = 0.2)
)
netwk <- rpanet(nstep = 10^4, control = control)
ret <- assortcoef(netwk)
ret <- assortcoef(
edgelist = netwk$edgelist,
edgeweight = netwk$edge.attr$weight,
directed = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.