dgl.transform.remove_self_loop

dgl.transform.remove_self_loop(g)[source]

Return a new graph with all self-loop edges removed

Examples

>>> g = DGLGraph()
>>> g.add_nodes(5)
>>> g.add_edges([0, 1, 2], [1, 1, 2])
>>> new_g = dgl.transform.remove_self_loop(g) # Nodes 1, 2 have self-loop
>>> new_g.edges()
(tensor([0]), tensor([1]))
Parameters:g (DGLGraph) –
Returns:
Return type:DGLGraph