r"""Remove multiple edges with the specified edge type Nodes will not be removed. After removing edges, the rest edges will be re-indexed using consecutive integers from 0, with their relative order preserved. The features for the removed edges will be removed accor
(self, eids, etype=None, store_ids=False)
| 627 | self._reset_cached_info() |
| 628 | |
| 629 | def remove_edges(self, eids, etype=None, store_ids=False): |
| 630 | r"""Remove multiple edges with the specified edge type |
| 631 | |
| 632 | Nodes will not be removed. After removing edges, the rest |
| 633 | edges will be re-indexed using consecutive integers from 0, |
| 634 | with their relative order preserved. |
| 635 | |
| 636 | The features for the removed edges will be removed accordingly. |
| 637 | |
| 638 | Parameters |
| 639 | ---------- |
| 640 | eids : int, tensor, numpy.ndarray, list |
| 641 | IDs for the edges to remove. |
| 642 | etype : str or tuple of str, optional |
| 643 | The type of the edges to remove. Can be omitted if there is |
| 644 | only one edge type in the graph. |
| 645 | store_ids : bool, optional |
| 646 | If True, it will store the raw IDs of the extracted nodes and edges in the ``ndata`` |
| 647 | and ``edata`` of the resulting graph under name ``dgl.NID`` and ``dgl.EID``, |
| 648 | respectively. |
| 649 | |
| 650 | Notes |
| 651 | ----- |
| 652 | This function preserves the batch information. |
| 653 | |
| 654 | Examples |
| 655 | -------- |
| 656 | |
| 657 | >>> import dgl |
| 658 | >>> import torch |
| 659 | |
| 660 | **Homogeneous Graphs or Heterogeneous Graphs with A Single Edge Type** |
| 661 | |
| 662 | >>> g = dgl.graph((torch.tensor([0, 0, 2]), torch.tensor([0, 1, 2]))) |
| 663 | >>> g.edata['he'] = torch.arange(3).float().reshape(-1, 1) |
| 664 | >>> g.remove_edges(torch.tensor([0, 1])) |
| 665 | >>> g |
| 666 | Graph(num_nodes=3, num_edges=1, |
| 667 | ndata_schemes={} |
| 668 | edata_schemes={'he': Scheme(shape=(1,), dtype=torch.float32)}) |
| 669 | >>> g.edges('all') |
| 670 | (tensor([2]), tensor([2]), tensor([0])) |
| 671 | >>> g.edata['he'] |
| 672 | tensor([[2.]]) |
| 673 | |
| 674 | Removing edges from a batched graph preserves batch information. |
| 675 | |
| 676 | >>> g = dgl.graph((torch.tensor([0, 0, 2]), torch.tensor([0, 1, 2]))) |
| 677 | >>> g2 = dgl.graph((torch.tensor([1, 2, 3]), torch.tensor([1, 3, 4]))) |
| 678 | >>> bg = dgl.batch([g, g2]) |
| 679 | >>> bg.batch_num_edges() |
| 680 | tensor([3, 3]) |
| 681 | >>> bg.remove_edges([1, 4]) |
| 682 | >>> bg.batch_num_edges() |
| 683 | tensor([2, 2]) |
| 684 | |
| 685 | **Heterogeneous Graphs with Multiple Edge Types** |
| 686 |