dgl.BatchedDGLHeteroGraph.batch_num_edges¶

BatchedDGLHeteroGraph.
batch_num_edges
(etype=None)[source]¶ Return the numbers of edges of the given type for all heterographs in the batch.
Parameters: etype (str or tuple of str, optional) – The edge type. Can be omitted if there is only one edge type in the graph. Returns: The ith element gives the number of edges of the specified type in the ith graph. Return type: list of int Examples
>>> g1 = dgl.heterograph({ ... ('user', 'follows', 'user'): [(0, 1), (1, 2)], ... ('user', 'follows', 'developer'): [(0, 1), (1, 2)], ... ('user', 'plays', 'game'): [(0, 0), (1, 0), (2, 1), (3, 1)] ... }) >>> g2 = dgl.heterograph({ ... ('user', 'follows', 'user'): [(0, 1), (1, 2)], ... ('user', 'follows', 'developer'): [(0, 1), (1, 2)], ... ('user', 'plays', 'game'): [(0, 0), (1, 0), (2, 1)] ... }) >>> bg = dgl.batch_hetero([g1, g2]) >>> bg.batch_num_edges('plays') [4, 3] >>> # 'follows' is ambiguous and we use ('user', 'follows', 'user') instead. >>> bg.batch_num_edges(('user', 'follows', 'user')) [2, 2]