attribute_assortativity_coefficient(G, attribute, nodes=None)
Assortativity measures the similarity of connections in the graph with respect to the given attribute.
This computes Eq. (2) in Ref. , (trace(M)-sum(M^2))/(1-sum(M^2)), where M is the joint probability distribution (mixing matrix) of the specified attribute.
Node attribute key
Compute attribute assortativity for nodes in container. The default is all nodes.
Assortativity of graph for given attribute
Compute assortativity for node attributes.
>>> G = nx.Graph()See :
... 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_coefficient(G, "color")) 1.0
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.assortativity.correlation.degree_assortativity_coefficient
networkx.algorithms.assortativity.correlation.attribute_assortativity_coefficient
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them