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
8adeb8fc
Commit
8adeb8fc
authored
5 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
bump
parent
e0f86229
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
graph_parameters.py
+13
-0
13 additions, 0 deletions
graph_parameters.py
test_cycle.py
+49
-8
49 additions, 8 deletions
test_cycle.py
with
62 additions
and
8 deletions
graph_parameters.py
+
13
−
0
View file @
8adeb8fc
...
...
@@ -155,6 +155,19 @@ class UnderlayingGraph(GraphParameterBase):
return
b
[
0
].
value
@Singleton
class
VertexCount
(
GraphParameterBase
):
CUBIC_VERTEX
=
[
Boundary
(
None
,
1
)
]
FREE_EDGE
=
[
Boundary
(
None
,
0
)
]
def
join_boundaries
(
self
,
x
,
_
):
yield
Boundary
(
None
,
sum
(
b
.
value
for
b
in
x
))
def
join_edges
(
self
,
b
,
_
,
__
):
yield
b
def
project_and_canonize
(
self
,
_
,
b
):
return
b
def
finalize
(
self
,
b
):
return
b
[
0
].
value
@Singleton
class
HamiltonianCycle
(
GraphParameterBase
):
FREE_EDGE
=
[
Boundary
((
1
,
1
),
1
),
Boundary
((
None
,
None
),
1
)
]
...
...
This diff is collapsed.
Click to expand it.
test_cycle.py
+
49
−
8
View file @
8adeb8fc
from
flower_snarks
import
*
from
sage.all
import
*
from
itertools
import
permutations
def
solve_gadget
(
g
,
alt_gadgets
):
N
=
g
.
size
()
...
...
@@ -17,25 +18,44 @@ def solve_gadget(g, alt_gadgets):
def
gadget_to_poly
(
gadget
):
return
sum
(
V
[
b
]
*
join
(
fake_gadget
(
b
),
gadget
).
eval
(
CircuitDoubleCover
)
V
[
b
]
*
float
(
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
(
)
n
=
VertexCount
.
finalize
(
gadget
.
eval
(
VertexCount
)
)
P
.
add_constraint
(
poly
>=
2
**
(
n
//
2
))
for
ag
in
alt_gadgets
:
gadget_to_constraint
(
ag
)
P
.
set_objective
(
gadget_to_poly
(
g
))
P
.
show
()
print
(
floor
(
P
.
solve
()),
2
**
(
g
.
eval
(
UnderlayingGraph
)[
0
].
value
.
num_verts
()
//
2
))
if
False
:
P
.
show
()
for
i
,
v
in
sorted
(
P
.
get_values
(
V
).
items
()):
print
(
'
w_%s = %s
'
%
(
i
,
v
))
return
(
floor
(
P
.
solve
()),
2
**
(
g
.
eval
(
UnderlayingGraph
)[
0
].
value
.
num_verts
()
//
2
))
def
friend_boundary
(
g
):
N
=
g
.
size
();
BOUNDARIES
=
list
(
CircuitDoubleCover
.
enumerate_boundaries
(
N
))
def
test_boundary
(
b
):
fg
=
FakeGadget
(
N
,
[
Boundary
(
b
,
1
)
])
joins
=
[
((
1
,
i
),
(
2
,
i
))
for
i
in
range
(
1
,
N
+
1
)
]
return
(
b
,
Gadget
.
join
([
fg
,
g
],
joins
,
[]).
eval
(
CircuitDoubleCover
))
return
[
test_boundary
(
b
)
for
b
in
BOUNDARIES
]
def
rot
(
l
,
x
):
return
l
[
x
:]
+
l
[:
x
]
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
)
]),
...
...
@@ -49,8 +69,29 @@ G4f = [
]
G5
=
[
Gadget
.
join
([
CUBIC_VERTEX
]
*
3
,
[((
1
,
1
),
(
2
,
1
)),
((
2
,
2
),
(
3
,
2
))],
[
(
1
,
2
),
(
1
,
3
),
(
2
,
3
),
(
3
,
1
),
(
3
,
3
)
]),
Gadget
.
join
([
CUBIC_VERTEX
]
*
3
,
[((
1
,
1
),
(
2
,
1
)),
((
2
,
2
),
(
3
,
2
))],
out
)
for
out
in
permutations
([
(
1
,
2
),
(
1
,
3
),
(
2
,
3
),
(
3
,
1
),
(
3
,
3
)
])
]
+
[
Gadget
.
join
([
CUBIC_VERTEX
,
FREE_EDGE
],
[],
out
)
for
out
in
permutations
([
(
1
,
1
),
(
1
,
2
),
(
1
,
3
),
(
2
,
1
),
(
2
,
2
)
])
]
G5s
=
[
Gadget
.
join
([
CUBIC_VERTEX
]
*
3
,
[((
1
,
1
),
(
2
,
1
)),
((
2
,
2
),
(
3
,
2
))],
rot
([
(
1
,
2
),
(
1
,
3
),
(
2
,
3
),
(
3
,
1
),
(
3
,
3
)
],
i
))
for
i
in
range
(
5
)
]
+
[
Gadget
.
join
([
CUBIC_VERTEX
,
FREE_EDGE
],
[],
rot
([
(
1
,
1
),
(
1
,
2
),
(
1
,
3
),
(
2
,
1
),
(
2
,
2
)
],
i
))
for
i
in
range
(
5
)
]
G6
=
[
Gadget
.
join
([
CUBIC_VERTEX
]
*
4
,
[((
1
,
1
),
(
2
,
1
)),
((
1
,
2
),
(
3
,
1
)),
((
1
,
3
),
(
4
,
1
))],
out
)
for
out
in
[[
(
2
,
2
),
(
2
,
3
),
(
3
,
2
),
(
3
,
3
),
(
4
,
2
),
(
4
,
3
)
]]
]
print
(
solve_gadget
(
sun
(
4
),
G4
))
# print(solve_gadget(G4[0], G4f))
l
=
sorted
(
friend_boundary
(
G4
[
0
]),
key
=
lambda
x
:
x
[
1
])
print
(
len
(
l
))
for
x
in
l
:
print
(
x
)
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