Skip to content

Commit ecaab20

Browse files
committed
Fix BipartiteGraph.vertex_cover(value_only=True) for disconnected graphs
1 parent 28b7af0 commit ecaab20

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/sage/graphs/bipartite_graph.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,8 @@ def vertex_cover(self, algorithm='Konig', value_only=False,
23452345
sage: B = BipartiteGraph(graphs.CycleGraph(4) * 2)
23462346
sage: len(B.vertex_cover()) # needs networkx
23472347
4
2348+
sage: B.vertex_cover(value_only=True) # needs networkx
2349+
4
23482350
23492351
Empty bipartite graph and bipartite graphs without edges::
23502352
@@ -2376,7 +2378,7 @@ def vertex_cover(self, algorithm='Konig', value_only=False,
23762378
if b.size():
23772379
VC.extend(b.vertex_cover(algorithm='Konig'))
23782380
if value_only:
2379-
return sum(VC)
2381+
return len(VC)
23802382
return VC
23812383

23822384
M = Graph(self.matching())

0 commit comments

Comments
 (0)