dgl.DGLGraph.remove_edges

DGLGraph.remove_edges(eids)[source]

Remove multiple edges.

Parameters:eids (list, tensor) – The id of edges to remove.

Notes

The nodes and edges in the graph would be re-indexed after the removal.

Examples

The following example uses PyTorch backend.

>>> import torch as th
>>> G = dgl.DGLGraph()
>>> G.add_nodes(5)
>>> G.add_edges([0, 1, 2, 3, 4], [1, 2, 3, 4, 0], {'x': th.arange(15).view(5, 3)})
>>> G.nodes()
tensor([0, 1, 2, 3, 4])
>>> G.edges()
(tensor([0, 1, 2, 3, 4]), tensor([1, 2, 3, 4, 0]))
>>> G.edata['x']
tensor([[ 0,  1,  2],
        [ 3,  4,  5],
        [ 6,  7,  8],
        [ 9, 10, 11],
        [12, 13, 14]])
>>> G.remove_edges([1, 2])
>>> G.nodes()
tensor([0, 1, 2, 3, 4])
>>> G.edges()
(tensor([0, 3, 4]), tensor([1, 4, 0]))
>>> G.edata['x']
tensor([[ 0,  1,  2],
        [ 9, 10, 11],
        [12, 13, 14]])