Skip to content
Snippets Groups Projects
Commit 58407d5b authored by Radek Hušek's avatar Radek Hušek
Browse files

implement enumerate_boundaries() for CycleDoubleCover

parent 2dda89dd
Branches
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ def _init_():
SimpleParameterBase, GraphParameterBase
from fractions import Fraction
from itertools import chain, combinations
from itertools import chain, combinations, product
from functools import reduce
from collections import defaultdict
......@@ -51,6 +51,18 @@ def _init_():
def is_compatible(self, boundary, e_a, e_b):
return boundary[e_a] == boundary[e_b]
def enumerate_boundaries(self, n):
tuples = [ (i, j) for j in range(self.k) for i in range(j) ]
def is_boundary(b):
counts = [0] * self.k
for i, j in b:
counts[i] += 1
counts[j] += 1
return all( c % 2 == 0 for c in counts )
return ( b for b in product(tuples, repeat=n) if is_boundary(b) )
@OneOfKind
class EdgeColoring(SimpleParameterBase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment