NetworkX

Previous topic

networkx.algorithms.mixing.numeric_assortativity

Next topic

networkx.algorithms.mixing.attribute_mixing_matrix

networkx.algorithms.mixing.degree_pearsonr

networkx.algorithms.mixing.degree_pearsonr(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 pearson correlation of degrees only for nodes in container. The default is all nodes.

Returns :

r : float

Assortativity of graph by degree.

Notes

This calls scipy.stats.pearsonr().

References

[R138]M. E. J. Newman, Mixing patterns in networks Physical Review E, 67 026126, 2003

Examples

>>> G=nx.path_graph(4)
>>> r=nx.degree_pearsonr(G) 
>>> r 
-0.5