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

Method num_nodes

python/dgl/distributed/dist_graph.py:1163–1190  ·  view source on GitHub ↗

Return the total number of nodes in the distributed graph. Parameters ---------- ntype : str, optional The node type name. If given, it returns the number of nodes of the type. If not given (default), it returns the total number of nodes of all types.

(self, ntype=None)

Source from the content-addressed store, hash-verified

1161 return self.num_edges(etype)
1162
1163 def num_nodes(self, ntype=None):
1164 """Return the total number of nodes in the distributed graph.
1165
1166 Parameters
1167 ----------
1168 ntype : str, optional
1169 The node type name. If given, it returns the number of nodes of the
1170 type. If not given (default), it returns the total number of nodes of all types.
1171
1172 Returns
1173 -------
1174 int
1175 The number of nodes
1176
1177 Examples
1178 --------
1179 >>> g = dgl.distributed.DistGraph('ogb-product')
1180 >>> print(g.num_nodes())
1181 2449029
1182 """
1183 if ntype is None:
1184 if len(self.ntypes) == 1:
1185 return self._gpb._num_nodes(self.ntypes[0])
1186 else:
1187 return sum(
1188 [self._gpb._num_nodes(ntype) for ntype in self.ntypes]
1189 )
1190 return self._gpb._num_nodes(ntype)
1191
1192 def num_edges(self, etype=None):
1193 """Return the total number of edges in the distributed graph.

Callers 15

number_of_nodesMethod · 0.95
out_degreesMethod · 0.95
in_degreesMethod · 0.95
edge_subgraphMethod · 0.95
run_clientFunction · 0.95
setup_moduleFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
__call__Method · 0.45
_sample_neighborsFunction · 0.45

Calls 2

_num_nodesMethod · 0.80
sumFunction · 0.50

Tested by 2

run_clientFunction · 0.76
setup_moduleFunction · 0.76