View source: R/assortativity.R
assortativity | R Documentation |
The assortativity coefficient is positive if similar vertices (based on some external property) tend to connect to each, and negative otherwise.
assortativity(
graph,
values,
...,
values.in = NULL,
directed = TRUE,
normalized = TRUE,
types1 = NULL,
types2 = NULL
)
assortativity_nominal(graph, types, directed = TRUE, normalized = TRUE)
assortativity_degree(graph, directed = TRUE)
graph |
The input graph, it can be directed or undirected. |
values |
The vertex values, these can be arbitrary numeric values. |
... |
These dots are for future extensions and must be empty. |
values.in |
A second value vector to use for the incoming edges when
calculating assortativity for a directed graph.
Supply |
directed |
Logical scalar, whether to consider edge directions for
directed graphs.
This argument is ignored for undirected graphs.
Supply
|
normalized |
Boolean, whether to compute the normalized assortativity. The non-normalized nominal assortativity is identical to modularity. The non-normalized value-based assortativity is simply the covariance of the values at the two ends of edges. |
types1 , types2 |
|
types |
Vector giving the vertex types. They as assumed to be integer
numbers, starting with one. Non-integer values are converted to integers
with |
The assortativity coefficient measures the level of homophyly of the graph, based on some vertex labeling or values assigned to vertices. If the coefficient is high, that means that connected vertices tend to have the same labels or similar assigned values.
M.E.J. Newman defined two kinds of assortativity coefficients, the first one
is for categorical labels of vertices. assortativity_nominal()
calculates this measure. It is defined as
r=\frac{\sum_i e_{ii}-\sum_i a_i b_i}{1-\sum_i a_i b_i}
where e_{ij}
is the fraction of edges connecting vertices of
type i
and j
, a_i=\sum_j e_{ij}
and
b_j=\sum_i e_{ij}
.
The second assortativity variant is based on values assigned to the
vertices. assortativity()
calculates this measure. It is defined as
r=\frac1{\sigma_q^2}\sum_{jk} jk(e_{jk}-q_j q_k)
for undirected graphs (q_i=\sum_j e_{ij}
) and as
r=\frac1{\sigma_o\sigma_i}\sum_{jk}jk(e_{jk}-q_j^o q_k^i)
for directed ones. Here q_i^o=\sum_j e_{ij}
,
q_i^i=\sum_j e_{ji}
, moreover,
\sigma_q
, \sigma_o
and
\sigma_i
are the standard deviations of q
,
q^o
and q^i
, respectively.
The reason of the difference is that in directed networks the relationship is not symmetric, so it is possible to assign different values to the outgoing and the incoming end of the edges.
assortativity_degree()
uses vertex degree as vertex values
and calls assortativity()
.
Undirected graphs are effectively treated as directed ones with all-reciprocal edges. Thus, self-loops are taken into account twice in undirected graphs.
A single real number.
igraph_assortativity()
, igraph_assortativity_nominal()
, igraph_assortativity_degree()
.
Gabor Csardi csardi.gabor@gmail.com
M. E. J. Newman: Mixing patterns in networks, Phys. Rev. E 67, 026126 (2003) https://arxiv.org/abs/cond-mat/0209450
M. E. J. Newman: Assortative mixing in networks, Phys. Rev. Lett. 89, 208701 (2002) https://arxiv.org/abs/cond-mat/0205405
# random network, close to zero
assortativity_degree(sample_gnp(10000, 3 / 10000))
# BA model, tends to be dissortative
assortativity_degree(sample_pa(10000, m = 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.