#

Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

#

networkx.algorithms.assortativity.node_attribute_xy

node_attribute_xy(G, attribute, nodes=None)[source]

Returns iterator of node-attribute pairs for all edges in G.

Parameters
  • G (NetworkX graph)

  • attribute (key) – The node attribute key.

  • 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 (attribute,attribute) values.

Return type

2-tuple

Examples

>>> G = nx.DiGraph()
>>> G.add_node(1, color="red")
>>> G.add_node(2, color="blue")
>>> G.add_edge(1, 2)
>>> list(nx.node_attribute_xy(G, "color"))
[('red', 'blue')]

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.