networkx.algorithms.assortativity.node_degree_xy¶
-
node_degree_xy
(G, x='out', y='in', weight=None, nodes=None)[source]¶ Generate node degree-degree pairs for edges in G.
- Parameters
G (NetworkX graph)
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).
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.
nodes (list or iterable (optional)) – Use only edges that are adjacency to specified nodes. The default is all nodes.
- Returns
(x,y) – Generates 2-tuple of (degree,degree) values.
- Return type
2-tuple
Examples
>>> G = nx.DiGraph() >>> G.add_edge(1, 2) >>> list(nx.node_degree_xy(G, x="out", y="in")) [(1, 1)] >>> list(nx.node_degree_xy(G, x="in", y="out")) [(0, 0)]
Notes
For undirected graphs each edge is produced twice, once for each edge representation (u,v) and (v,u), with the exception of self-loop edges which only appear once.