networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
degree_mixing_matrix(G, x='out', y='in', weight=None, nodes=None, normalized=True, mapping=None)

Notes

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.

Parameters

G : graph

NetworkX graph object.

x: string ('in','out') :

The degree type for source node (directed graphs only).

y: string ('in','out') :

The degree type for target node (directed graphs only).

nodes: list or iterable (optional) :

Build the matrix using only nodes in container. The default is all nodes.

weight: string or None, optional (default=None) :

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.

normalized : bool (default=True)

Return counts if False or probabilities if True.

mapping : dictionary, optional

Mapping from node degree to integer index in matrix. If not specified, an arbitrary ordering will be used.

Returns

m: numpy array

Counts, or joint probability, of occurrence of node degree.

Returns mixing matrix for attribute.

Examples

>>> 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)
... 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
See :

Back References

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

Local connectivity graph

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


GitHub : /networkx/algorithms/assortativity/mixing.py#145
type: <class 'function'>
Commit: