Learn R Programming

wdnet (version 1.2.3)

assortcoef: Compute the assortativity coefficient(s) for a network.

Description

Compute the assortativity coefficient(s) for a network.

Usage

assortcoef(netwk, edgelist, edgeweight, adj, directed, f1, f2)

Value

Assortativity coefficient for undirected networks, or a list of four assortativity coefficients for directed networks.

Arguments

netwk

A wdnet object that represents the network. If NULL, the function will compute the coefficient using either edgelist and edgeweight, or adj.

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 NULL, all edges will be assigned weight 1.

adj

The adjacency matrix of a network.

directed

Logical. Indicates whether the edges in edgelist or adj are directed. It will be omitted if netwk is provided.

f1

A vector representing the first feature of existing nodes. The number of nodes should be equal to the length of both f1 and f2. Defined for directed networks. If NULL, out-strength will be used.

f2

A vector representing the second feature of existing nodes. Defined for directed networks. If NULL, in-strength will be used.

References

  • 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.

Examples

Run this code
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
)

Run the code above in your browser using DataLab