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

test_cycle

parent 146e9b38
No related branches found
No related tags found
No related merge requests found
...@@ -335,6 +335,13 @@ Petersen = Gadget.join( ...@@ -335,6 +335,13 @@ Petersen = Gadget.join(
) )
def sun(k):
return Gadget.join(
[ CUBIC_VERTEX ] * k,
[ ((i + 1, 2), ((i+1) % k + 1, 1)) for i in range(k) ],
[ (i + 1, 3) for i in range(k) ]
)
def count_cdc_naive(G): def count_cdc_naive(G):
assert(G.degree() == [3]*G.num_verts()) assert(G.degree() == [3]*G.num_verts())
......
from flower_snarks import *
from sage.all import *
def solve_gadget(g, alt_gadgets):
N = g.size()
P = MixedIntegerLinearProgram(maximization=False)
V = P.new_variable(real=True, nonnegative=True)
BOUNDARIES = list(CircuitDoubleCover.enumerate_boundaries(N))
def fake_gadget(b):
return FakeGadget(N, [ Boundary(b, 1) ])
def join(a, b):
return Gadget.join([ a, b ], [ ((1, i), (2, i)) for i in range(1,N+1) ], [])
def gadget_to_poly(gadget):
return sum(
V[b] * join(fake_gadget(b), gadget).eval(CircuitDoubleCover)
for b in BOUNDARIES
)
def gadget_to_constraint(gadget):
poly = gadget_to_poly(gadget)
n = gadget.eval(UnderlayingGraph)[0].value.num_verts()
P.add_constraint(poly >= 2**(n // 2))
for ag in alt_gadgets: gadget_to_constraint(ag)
P.set_objective(gadget_to_poly(g))
return (floor(P.solve()), 2**(g.eval(UnderlayingGraph)[0].value.num_verts()//2))
G4 = [
Gadget.join([CUBIC_VERTEX] * 2, [((1,1), (2,1))], [ (1,2), (1,3), (2,2), (2,3) ]),
Gadget.join([CUBIC_VERTEX] * 2, [((1,1), (2,1))], [ (1,2), (2,2), (1,3), (2,3) ]),
Gadget.join([CUBIC_VERTEX] * 2, [((1,1), (2,1))], [ (1,2), (2,2), (2,3), (1,3) ]),
]
G4f = [
Gadget.join([FREE_EDGE]*2, [], [ (1,1), (1,2), (2,1), (2,2) ]),
Gadget.join([FREE_EDGE]*2, [], [ (1,1), (2,1), (1,2), (2,2) ]),
Gadget.join([FREE_EDGE]*2, [], [ (1,1), (2,1), (2,2), (1,2) ]),
]
G5 = [
Gadget.join([CUBIC_VERTEX] * 3, [((1,1), (2,1)), ((2,2), (3,2))], [ (1,2), (1,3), (2,3), (3,1), (3,3) ]),
]
print(solve_gadget(sun(5), G5))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment