MCPcopy
hub / github.com/dmlc/dgl / out_degrees

Method out_degrees

python/dgl/distributed/dist_graph.py:1227–1274  ·  view source on GitHub ↗

Return the out-degree(s) of the given nodes. It computes the out-degree(s). It does not support heterogeneous graphs yet. Parameters ---------- u : node IDs The node IDs. The allowed formats are: * ``int``: A single node.

(self, u=ALL)

Source from the content-addressed store, hash-verified

1225 return self._gpb._num_edges(etype)
1226
1227 def out_degrees(self, u=ALL):
1228 """Return the out-degree(s) of the given nodes.
1229
1230 It computes the out-degree(s).
1231 It does not support heterogeneous graphs yet.
1232
1233 Parameters
1234 ----------
1235 u : node IDs
1236 The node IDs. The allowed formats are:
1237
1238 * ``int``: A single node.
1239 * Int Tensor: Each element is a node ID. The tensor must have the same device type
1240 and ID data type as the graph's.
1241 * iterable[int]: Each element is a node ID.
1242
1243 If not given, return the in-degrees of all the nodes.
1244
1245 Returns
1246 -------
1247 int or Tensor
1248 The out-degree(s) of the node(s) in a Tensor. The i-th element is the out-degree
1249 of the i-th input node. If :attr:`v` is an ``int``, return an ``int`` too.
1250
1251 Examples
1252 --------
1253 The following example uses PyTorch backend.
1254
1255 >>> import dgl
1256 >>> import torch
1257
1258 Query for all nodes.
1259
1260 >>> g.out_degrees()
1261 tensor([2, 2, 0, 0])
1262
1263 Query for nodes 1 and 2.
1264
1265 >>> g.out_degrees(torch.tensor([1, 2]))
1266 tensor([2, 0])
1267
1268 See Also
1269 --------
1270 in_degrees
1271 """
1272 if is_all(u):
1273 u = F.arange(0, self.num_nodes())
1274 return dist_out_degrees(self, u)
1275
1276 def in_degrees(self, v=ALL):
1277 """Return the in-degree(s) of the given nodes.

Callers 13

start_get_degrees_clientFunction · 0.95
node_samplerMethod · 0.45
edge_samplerMethod · 0.45
_out_degreesFunction · 0.45
libra_partitionFunction · 0.45
forwardMethod · 0.45
callMethod · 0.45
forwardMethod · 0.45
__init__Method · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
get_mcts_childrenMethod · 0.45

Calls 2

num_nodesMethod · 0.95
is_allFunction · 0.85

Tested by 1

start_get_degrees_clientFunction · 0.76