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
b7a69e8e
Commit
b7a69e8e
authored
4 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
generate better gadget decompositions
parent
5473738a
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
experiments/test_exp_cdc.sh
+8
-5
8 additions, 5 deletions
experiments/test_exp_cdc.sh
graph_tools/misc.py
+19
-9
19 additions, 9 deletions
graph_tools/misc.py
with
27 additions
and
14 deletions
experiments/test_exp_cdc.sh
+
8
−
5
View file @
b7a69e8e
...
...
@@ -40,19 +40,22 @@ if True:
sys.path.append(sys.argv[1] + "/..")
import json
from graph_tools.misc import count_cdc_naive
from graph_tools.misc import graph_to_gadget
from graph_tools.parameters import CircuitDoubleCover
from sage.all import Graph
from parmap import parmap
def process(l):
G = Graph(l)
ret = count_cdc_naive(G)
gadget = graph_to_gadget(G)
real = gadget.eval(CircuitDoubleCover)
exp = 2**(G.num_verts() // 2) // 2
j = {
"cdc_count": re
t[0]
,
"cdc_count": re
al
,
"n": G.num_verts(),
"expected_cdc_lowerbound":
ret[1]
,
"is_ok": (re
t[0] >= ret[1]
)
"expected_cdc_lowerbound":
exp
,
"is_ok": (re
al >= exp
)
}
return json.dumps(j), j["is_ok"]
...
...
This diff is collapsed.
Click to expand it.
graph_tools/misc.py
+
19
−
9
View file @
b7a69e8e
...
...
@@ -16,15 +16,22 @@ def _init_():
)
def
count_cdc
_naive
(
G
):
"""
Count circuit double covers of G
.
def
graph_to_gadget
_naive
(
G
):
"""
Transform graph into a Gadget
.
Requires G to be cubic
.
Very naive (and hence obviously correct) implementation
.
EXAMPLE:
EXAMPLE
S
:
>>>
from
sage.all
import
*
>>>
count_cdc_naive
(
graphs
.
PetersenGraph
())
(
52
,
16
)
>>>
from
.parameters
import
CircuitDoubleCover
,
UnderlayingGraph
>>>
P
=
graphs
.
PetersenGraph
()
>>>
graph_to_gadget_naive
(
P
).
eval
(
CircuitDoubleCover
)
52
>>>
d
=
[
list
(
range
(
5
)),
list
(
range
(
5
,
10
))
]
>>>
P
.
is_isomorphic
(
graph_to_gadget_naive
(
P
,
d
).
eval
(
UnderlayingGraph
))
True
>>>
graph_to_gadget_naive
(
P
,
d
).
eval
(
CircuitDoubleCover
)
52
"""
assert
(
G
.
degree
()
==
[
3
]
*
G
.
num_verts
())
...
...
@@ -42,7 +49,7 @@ def _init_():
b
=
Gadget
.
join
([
CUBIC_VERTEX
]
*
G
.
num_verts
(),
joins
,
[])
assert
b
.
is_graph
()
return
(
b
.
eval
(
CircuitDoubleCover
),
2
**
(
G
.
num_verts
()
//
2
)
//
2
)
return
b
def
graph_to_gadget
(
G
,
decomposition
=
None
,
allow_non_graph
=
False
):
...
...
@@ -69,7 +76,9 @@ def _init_():
edges
=
[
(
verts
[
u
],
verts
[
v
])
for
u
,
v
,
_
in
G
.
edges
()
]
if
decomposition
is
None
:
decomposition
=
G
.
vertices
()
decomposition
=
G
.
vertices
()[
0
]
for
v
in
G
.
vertices
()[
1
:]:
decomposition
=
[
v
,
decomposition
]
vert_map
=
{
v
:
[
0
,
1
,
2
]
for
v
in
range
(
len
(
verts
))
}
...
...
@@ -109,7 +118,8 @@ def _init_():
for
i
in
old
:
outs
.
append
((
vert_to_gadget
[
v
]
+
1
,
i
+
1
))
return
(
Gadget
.
join
([
g
for
g
,
_
in
gadgets
],
joins
,
outs
),
gadget_verts
)
ret
=
Gadget
.
join
([
g
for
g
,
_
in
gadgets
],
joins
,
outs
)
return
(
ret
,
gadget_verts
)
b
,
_
=
process
(
decomposition
)
assert
allow_non_graph
or
b
.
is_graph
()
...
...
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