Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdc-counting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radek Hušek
cdc-counting
Commits
06433271
Commit
06433271
authored
5 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
test_cycle
parent
146e9b38
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
flower_snarks.py
+7
-0
7 additions, 0 deletions
flower_snarks.py
test_cycle.py
+53
-0
53 additions, 0 deletions
test_cycle.py
with
60 additions
and
0 deletions
flower_snarks.py
+
7
−
0
View file @
06433271
...
@@ -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
())
...
...
This diff is collapsed.
Click to expand it.
test_cycle.py
0 → 100644
+
53
−
0
View file @
06433271
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
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment