View source: R/assortativity.R
| assortativity | R Documentation |
Computes the degree assortativity coefficient, measuring the tendency of nodes to connect to other nodes with similar degree. Positive values indicate assortative mixing (high-degree nodes connect to high-degree nodes), negative values indicate disassortative mixing.
assortativity(x, directed = NULL, type = NULL, digits = NULL, ...)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
type |
Character string specifying which degree correlation to compute.
One of |
digits |
Integer or NULL. Round result to this many decimal places. Default NULL (no rounding). |
... |
Additional arguments passed to |
The degree assortativity coefficient is defined as the Pearson correlation coefficient between the degrees of nodes at either end of each edge (Newman 2002):
r = \frac{\sum_{jk} jk(e_{jk} - q_j q_k)}{\sigma_q^2}
where e_{jk} is the fraction of edges connecting degree-j to
degree-k vertices, q_k is the excess degree distribution, and
\sigma_q^2 its variance.
For directed networks, different degree combinations (in/out) at source and
target ends can be specified via the type parameter.
An object of class "cograph_assortativity" with components:
Numeric scalar: the assortativity coefficient in
[-1, 1].
Character: the degree type used.
Logical: whether the network was treated as directed.
Integer: number of nodes.
Integer: number of edges.
The original input network.
Newman, M.E.J. (2002). Assortative mixing in networks. Physical Review Letters, 89(20), 208701. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1103/PhysRevLett.89.208701")}
assortativity_attribute, centrality,
network_summary
# Assortative network (high-degree connect to high-degree)
adj <- matrix(c(
0, 1, 1, 1, 0,
1, 0, 1, 1, 0,
1, 1, 0, 0, 1,
1, 1, 0, 0, 1,
0, 0, 1, 1, 0
), 5, 5)
rownames(adj) <- colnames(adj) <- LETTERS[1:5]
cograph::assortativity(adj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.