'A NodeView of the Graph as G.nodes or G.nodes().
Can be used as `G.nodes` for data lookup and for set-like operations.
Can also be used as `G.nodes(data=False, default=None)` to return a
NodeDataView which allows control over node data but no set operations.
Parameters
data : string or bool, optional (default=False)
The node attribute returned in 2-tuple (n, ddict[data]).
If True, return entire node attribute dict as (n, ddict).
If False, return just the nodes n.
default : value, optional (default=None)
Value used for nodes that dont have the requested attribute.
Only relevant if data is not True or False.
Returns
NodeView
Allows set-like operations over the nodes as well as node
attribute dict lookup and calling to get a NodeDataView.
A NodeDataView iterates over `(n, data)` and has no set operations.
A NodeView iterates over `n` and includes set operations.
When called, if data is False, an iterator over nodes.
Otherwise an iterator of 2-tuples (node, attribute value)
where the attribute is specified in `data`.
If data is True then the attribute becomes the
entire data dictionary.
Notes
If the node data is not required, it is simpler and equivalent
to use the expression ``for n in G``, or ``list(G)``.
Examples
There are two simple ways of getting a list of all nodes in the graph:
>>> G = nx.path_graph(3)
>>> list(G.nodes())
[0, 1, 2]
>>> list(G)
[0, 1, 2]
To get the node data along with the nodes:
>>> G.add_node(1, time=\'5pm\')
>>> G.nodes[0][\'foo\'] = \'bar\'
>>> list(G.nodes(data=True))
[(0, {\'foo\': \'bar\'}), (1, {\'time\': \'5pm\'}), (2, {})]
>>> list(G.nodes(data=\'foo\'))
[(0, \'bar\'), (1, None), (2, None)]
>>> list(G.nodes(data=\'time\'))
[(0, None), (1, \'5pm\'), (2, None)]
>>> list(G.nodes(data=\'time\', default=\'Not Available\'))
[(0, \'Not Available\'), (1, \'5pm\'), (2, \'Not Available\')]
If some of your nodes have an attribute and the rest are assumed
to have a default attribute value you can create a dictionary
from node/attribute pairs using the `default` keyword argument
to guarantee the value is never None::
>>> G = nx.Graph()
>>> G.add_node(0)
>>> G.add_node(1, weight=2)
>>> G.add_node(2, weight=3)
>>> dict(G.nodes(data=\'weight\', default=1))
{0: 1, 1: 2, 2: 3}'

@property
def nodes(self):

    nodes = NodeView(self)
    self.__dict__['nodes'] = nodes
    return nodes
