# dgl.DGLHeteroGraph.number_of_edges¶

DGLHeteroGraph.number_of_edges(etype=None)[source]

Return the number of edges of the given type in the heterograph.

Parameters: etype (str or tuple of str, optional) – The edge type. Can be omitted if there is only one edge type in the graph. The number of edges int

Examples

>>> g = dgl.graph([(0, 1), (1, 2)], 'user', 'follows')
>>> g.number_of_edges(('user', 'follows', 'user'))
>>> g.number_of_edges('follows')
2
>>> g.number_of_edges()
2