NetworkX

Previous topic

networkx.algorithms.mixing.degree_assortativity

Next topic

networkx.algorithms.mixing.numeric_assortativity

networkx.algorithms.mixing.attribute_assortativity

networkx.algorithms.mixing.attribute_assortativity(G, attribute)

Compute assortativity for node attributes.

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

Parameters :

G : NetworkX graph

attribute : string

Node attribute key

Returns :

a: float :

Assortativity of given attribute

Notes

This computes Eq. (2) in Ref. [R95] , (trace(e)-sum(e))/(1-sum(e)), where e is the joint probability distribution (mixing matrix) of the specified attribute.

References

[R95](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],color='red')
>>> G.add_nodes_from([2,3],color='blue')
>>> G.add_edges_from([(0,1),(2,3)])
>>> print(nx.attribute_assortativity(G,'color'))
1.0