dgl.DGLGraph.out_degrees

DGLGraph.out_degrees(v='__ALL__')

Return the array d of out-degrees of the node array v.

d[i] is the out-degree of node v[i].

Parameters:v (list, tensor) – The node ID array. Default is to return the degrees of all the nodes.
Returns:d – The out-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.out_degrees([0, 1])
tensor([2, 1])

See also

out_degree()