NetworkX

Previous topic

networkx.algorithms.mixing.attribute_mixing_dict

Next topic

networkx.algorithms.mixing.attribute_assortativity

networkx.algorithms.mixing.degree_assortativity

networkx.algorithms.mixing.degree_assortativity(G, nodes=None)

Compute degree assortativity of graph.

Assortativity measures the similarity of connections in the graph with respect to the node degree.

Parameters :

G : NetworkX graph

nodes: list or iterable (optional) :

Compute degree assortativity only for nodes in container. The default is all nodes.

Returns :

r : float

Assortativity of graph by degree.

Notes

This computes Eq. (21) in Ref. [R137] , where e is the joint probability distribution (mixing matrix) of the degrees. If G is directed than the matrix e is the joint probability of out-degree and in-degree.

References

[R137](1, 2) M. E. J. Newman, Mixing patterns in networks, Physical Review E, 67 026126, 2003

Examples

>>> G=nx.path_graph(4)
>>> r=nx.degree_assortativity(G)
>>> print("%3.1f"%r)
-0.5