dgl.DGLGraph.in_degrees¶
-
DGLGraph.
in_degrees
(v='__ALL__')[source]¶ Return the array d of in-degrees of the node array v.
d[i] is the in-degree of node v[i].
Parameters: v (list, tensor, optional.) – The node ID array. Default is to return the degrees of all the nodes. Returns: d – The in-degree array. Return type: tensor Examples
The following example uses PyTorch backend.
>>> G = dgl.DGLGraph() >>> G.add_nodes(3) >>> G.add_edges([0, 0, 1], [1, 2, 2]) # (0, 1), (0, 2), (1, 2) >>> G.in_degrees([1, 2]) tensor([1, 2])
See also