networkx.node_attribute_xy¶
-
networkx.node_attribute_xy(G, attribute, nodes=None)[source]¶ Return 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): 2-tuple
Generates 2-tuple of (attribute,attribute) values.
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.
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')]