NetworkX

Previous topic

networkx.algorithms.mixing.attribute_assortativity

Next topic

networkx.algorithms.mixing.degree_pearsonr

networkx.algorithms.mixing.numeric_assortativity

networkx.algorithms.mixing.numeric_assortativity(G, attribute, nodes=None)

Compute assortativity for numerical node attributes.

Assortativity measures the similarity of connections in the graph with respect to the given numeric attribute.

Parameters :

G : NetworkX graph

attribute : string

Node attribute key

nodes: list or iterable (optional) :

Compute numeric assortativity only for attributes of nodes in container. The default is all nodes.

Returns :

a: float :

Assortativity of given attribute

Notes

This computes Eq. (21) in Ref. [R139] , where e is the joint probability distribution (mixing matrix) of the specified attribute.

References

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

Examples

>>> G=nx.Graph()
>>> G.add_nodes_from([0,1],size=2)
>>> G.add_nodes_from([2,3],size=3)
>>> G.add_edges_from([(0,1),(2,3)])
>>> print(nx.numeric_assortativity(G,'size'))
1.0