degree_mixing_matrix(G, x='out', y='in', weight=None, nodes=None, normalized=True, mapping=None)
Definitions of degree mixing matrix vary on whether the matrix should include rows for degree values that don't arise. Here we do not include such empty-rows. But you can force them to appear by inputting a :None:None:`mapping`
that includes those values. See examples.
NetworkX graph object.
The degree type for source node (directed graphs only).
The degree type for target node (directed graphs only).
Build the matrix using only nodes in container. The default is all nodes.
The edge attribute that holds the numerical value used as a weight. If None, then each edge has weight 1. The degree is the sum of the edge weights adjacent to the node.
Return counts if False or probabilities if True.
Mapping from node degree to integer index in matrix. If not specified, an arbitrary ordering will be used.
Counts, or joint probability, of occurrence of node degree.
Returns mixing matrix for attribute.
>>> G = nx.star_graph(3)
... mix_mat = nx.degree_mixing_matrix(G)
... mix_mat[0, 1] # mixing from node degree 1 to node degree 3 0.5
If you want every possible degree to appear as a row, even if no nodes have that degree, use :None:None:`mapping`
as follows,
>>> max_degree = max(deg for n, deg in G.degree)See :
... mapping = {x: x for x in range(max_degree + 1)} # identity mapping
... mix_mat = nx.degree_mixing_matrix(G, mapping=mapping)
... mix_mat[3, 1] # mixing from node degree 3 to node degree 1 0.5
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.mixing.degree_mixing_matrix
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