(self)
| 708 | G.add_edge(None, "anything") |
| 709 | |
| 710 | def test_add_edges_from(self): |
| 711 | G = self.Graph() |
| 712 | G.add_edges_from([(0, 1), (0, 2, {"weight": 3})]) |
| 713 | assert G.adj == { |
| 714 | 0: {1: {}, 2: {"weight": 3}}, |
| 715 | 1: {0: {}}, |
| 716 | 2: {0: {"weight": 3}}, |
| 717 | } |
| 718 | G = self.Graph() |
| 719 | G.add_edges_from([(0, 1), (0, 2, {"weight": 3}), (1, 2, {"data": 4})], data=2) |
| 720 | assert G.adj == { |
| 721 | 0: {1: {"data": 2}, 2: {"weight": 3, "data": 2}}, |
| 722 | 1: {0: {"data": 2}, 2: {"data": 4}}, |
| 723 | 2: {0: {"weight": 3, "data": 2}, 1: {"data": 4}}, |
| 724 | } |
| 725 | |
| 726 | with pytest.raises(nx.NetworkXError): |
| 727 | G.add_edges_from([(0,)]) # too few in tuple |
| 728 | with pytest.raises(nx.NetworkXError): |
| 729 | G.add_edges_from([(0, 1, 2, 3)]) # too many in tuple |
| 730 | with pytest.raises(TypeError): |
| 731 | G.add_edges_from([0]) # not a tuple |
| 732 | with pytest.raises(ValueError): |
| 733 | G.add_edges_from([(None, 3), (3, 2)]) # None cannot be a node |
| 734 | |
| 735 | def test_remove_edge(self): |
| 736 | G = self.K3.copy() |
nothing calls this directly
no test coverage detected