Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #19358: Wrong results in Graph.treewidth()
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanncohen committed Oct 5, 2015
1 parent 698579c commit 7667bf2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/sage/graphs/graph.py
Expand Up @@ -2736,6 +2736,15 @@ def treewidth(self,k=None,certificate=False):
....: g.delete_edges(list(combinations(bag,2)))
sage: g.size()
0
:trac:`19358`::
sage: g = Graph()
sage: for i in range(3):
....: for j in range(2):
....: g.add_path([i,(i,j),(i+1)%3])
sage: g.treewidth()
2
"""
from sage.misc.cachefunc import cached_function
from sage.sets.set import Set
Expand Down Expand Up @@ -2781,9 +2790,8 @@ def rec(cut,cc):
if len(cc)+len(cut) <= k+1:
return [(cut,cut.union(cc))] if certificate else True

# The list of potential vertices that could be added to the current cut
extensions = {v for u in cut for v in g.neighbors(u) if v in cc}
for v in extensions:
# We explore all possible extensions of the cut
for v in cc:

# New cuts and connected components, with v respectively added and
# removed
Expand Down

0 comments on commit 7667bf2

Please sign in to comment.