# dgl.DGLHeteroGraph.ndata¶

DGLHeteroGraph.ndata

Return the data view of all the nodes.

Only works if the graph has one node type.

Examples

The following example uses PyTorch backend.

To set features of all nodes in a heterogeneous graph with only one node type:

>>> g = dgl.graph([(0, 1), (1, 2)], 'user', 'follows')
>>> g.ndata['h'] = torch.zeros(3, 5)