Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
nodes¶
-
Graph.
nodes
(data=False)[source]¶ Return a list of the nodes in the graph.
Parameters: data : boolean, optional (default=False)
If False return a list of nodes. If True return a two-tuple of node and node data dictionary
Returns: nlist : list
A list of nodes. If data=True a list of two-tuples containing (node, node data dictionary).
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.add_path([0,1,2]) >>> G.nodes() [0, 1, 2] >>> G.add_node(1, time='5pm') >>> G.nodes(data=True) [(0, {}), (1, {'time': '5pm'}), (2, {})]