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

tests

parent b3c4a53e
Branches
No related tags found
No related merge requests found
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
>>> from .all import * >>> from .all import *
>>> from sage.all import * >>> from sage.all import *
>>> is_isomorphic = lambda g, gadget: g.is_isomorphic(gadget.eval(UnderlayingGraph)) >>> g2g = lambda gadget: gadget.eval(UnderlayingGraph)
>>> assert is_isomorphic(graphs.CompleteGraph(4), Necklace.graph(1)) >>> assert graphs.CompleteGraph(4).is_isomorphic(g2g(Necklace.graph(1)))
>>> assert is_isomorphic(graphs.PetersenGraph(), Petersen) >>> assert graphs.PetersenGraph().is_isomorphic(g2g(Petersen))
>>> assert all( \
g2g(CyclicLadder().graph(i)).is_isomorphic(g2g(GeneralizedPetersen(1).graph(i))) \
for i in range(3, 20) )
>>> cdc_count = lambda gadget: gadget.eval(CircuitDoubleCover) >>> cdc_count = lambda gadget: gadget.eval(CircuitDoubleCover)
>>> cdc_count(Petersen) >>> cdc_count(Petersen)
52 52
...@@ -18,13 +20,26 @@ ...@@ -18,13 +20,26 @@
True True
>>> all( cdc_count(Flower.graph(k)) == (2**(k-1) + (-1)**k) // 3 + 1 for k in range(3, 20) ) >>> all( cdc_count(Flower.graph(k)) == (2**(k-1) + (-1)**k) // 3 + 1 for k in range(3, 20) )
True True
>>> Necklace.stabilize(CircuitDoubleCover) >>> Necklace.stabilize(CircuitDoubleCover)
Loop 1 done - 1 boundaries (0 new) Loop 1 done - 1 boundaries (0 new)
{'variables': [((1, 2), (1, 2), None)], 'step_matrix': [4], 'initial_vector': [2], \ {'variables': [((1, 2), (1, 2), None)], 'step_matrix': [4], 'initial_vector': [2], \
'finalize': [1], 'simplified': ([1], [4], [2]), 'formula': 1/2*4^k} 'finalize': [1], 'simplified': ([1], [4], [2]), 'formula': 1/2*4^k, 'formula_if': k - 1 >= 0}
>>> Flower.stabilize(CircuitDoubleCover, 2)['formula'] >>> Flower.stabilize(CircuitDoubleCover, 2)['formula']
Loop 1 done - 3 boundaries (0 new) Loop 1 done - 3 boundaries (0 new)
1/3*2^(k - 1) + 1/3*(-1)^k + 1 1/3*2^(k - 1) + 1/3*(-1)^k + 1
>>> f = CyclicLadder().stabilize(CircuitDoubleCover, start_at=1)['formula']; f
Loop 1 done - 6 boundaries (6 new)
Loop 2 done - 13 boundaries (6 new)
Loop 3 done - 15 boundaries (2 new)
Loop 4 done - 15 boundaries (0 new)
1/2*(-1)^k*(k - 1) + 1/6*4^(k - 1) + 3*2^(k - 1) + 1/3*(-2)^(k - 2) - 5/2*k - 3/2
>>> assert all( f(k=k) == cdc_count(CyclicLadder().graph(k)) for k in range(3, 10) )
>>> f = CyclicLadder(crossed=True).stabilize(CircuitDoubleCover, start_at=3)['formula']; f
Loop 1 done - 12 boundaries (4 new)
Loop 2 done - 14 boundaries (0 new)
-1/2*(-1)^k*k + 1/6*4^(k - 1) + 3*2^(k - 1) + 1/3*(-2)^(k - 2) - 5/2*k
>>> assert all( f(k=k) == cdc_count(CyclicLadder(True).graph(k)) for k in range(3, 10) )
>>> sun_cdc = lambda n: sum( b.value for b in sun(n).eval_gadget(CircuitDoubleCover) ) >>> sun_cdc = lambda n: sum( b.value for b in sun(n).eval_gadget(CircuitDoubleCover) )
>>> all( sun_cdc(n) == 2**n - 2*n for n in range(3, 10) ) >>> all( sun_cdc(n) == 2**n - 2*n for n in range(3, 10) )
True True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment