Processing math: 100%
Skip to contents

The assortativity coefficient is positive is similar vertices (based on some external property) tend to connect to each, and negative otherwise.

Usage

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)

Arguments

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 be using for the incoming edges when calculating assortativity for a directed graph. Supply NULL here if you want to use the same values for outgoing and incoming edges. This argument is ignored (with a warning) if it is not NULL and undirected assortativity coefficient is being calculated.

directed

Logical scalar, whether to consider edge directions for directed graphs. This argument is ignored for undirected graphs. Supply TRUE here to do the natural thing, i.e. use directed version of the measure for directed graphs and the undirected version for undirected graphs.

normalized

TBD

types1, types2

[Deprecated] Deprecated aliases for values and values.in, respectively.

types

Vector giving the vertex types. They as assumed to be integer numbers, starting with one. Non-integer values are converted to integers with as.integer().

Value

A single real number.

Details

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 defines as

r=ieiiiaibi1iaibi

where eij is the fraction of edges connecting vertices of type i and j, ai=jeij and bj=ieij.

The second assortativity variant is based on values assigned to the vertices. assortativity() calculates this measure. It is defined as

r=1σ2qjkjk(ejkqjqk)

for undirected graphs (qi=jeij) and as

r=1σoσijkjk(ejkqojqik)

for directed ones. Here qoi=jeij, qii=jeji, moreover, σq, sigmao and sigmai are the standard deviations of q, qo and qi, 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 (minus one) as vertex values and calls assortativity().

References

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

Author

Gabor Csardi csardi.gabor@gmail.com

Examples


# random network, close to zero
assortativity_degree(sample_gnp(10000, 3 / 10000))
#> [1] -0.003901217

# BA model, tends to be dissortative
assortativity_degree(sample_pa(10000, m = 4))
#> [1] -0.02572967