Skip to content

Commit e1a3672

Browse files
author
Release Manager
committed
gh-40730: fix issue in method delete_vertices for bipartite graphs Fixes #39756. This PR is a refreshed version of #39813. It ensures that deleted vertices are also removed from the left and right sets of vertices of the bipartite graph. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40730 Reported by: David Coudert Reviewer(s):
2 parents 95518b8 + 53ce373 commit e1a3672

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/sage/graphs/bipartite_graph.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,15 @@ def __init__(self, data=None, partition=None, check=True, hash_labels=None, *arg
401401
Traceback (most recent call last):
402402
...
403403
TypeError: this graph is immutable and so cannot be changed
404+
405+
Check that :issue:`39756` is fixed::
406+
407+
sage: B = BipartiteGraph([(0,2), (0,3), (1,2), (1,3)])
408+
sage: B.left, B.right
409+
({0, 1}, {2, 3})
410+
sage: B.clear()
411+
sage: B.left, B.right
412+
(set(), set())
404413
"""
405414
if kwds is None:
406415
kwds = {'loops': False}
@@ -943,7 +952,20 @@ def delete_vertices(self, vertices):
943952
Traceback (most recent call last):
944953
...
945954
ValueError: vertex (0) not in the graph
955+
956+
TESTS:
957+
958+
Check that :issue:`39756` is fixed::
959+
960+
sage: B = BipartiteGraph([(0,2), (0,3), (1,2), (1,3)])
961+
sage: B.left, B.right
962+
({0, 1}, {2, 3})
963+
sage: B.delete_vertices(B.vertex_iterator())
964+
sage: B.left, B.right
965+
(set(), set())
946966
"""
967+
vertices = list(vertices)
968+
947969
# remove vertices from the graph
948970
Graph.delete_vertices(self, vertices)
949971

0 commit comments

Comments
 (0)