Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
group-connectivity-pub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
group-connectivity-pub
Commits
0efdd348
Commit
0efdd348
authored
9 years ago
by
Radek Hušek
Committed by
Radek Hušek
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Implement Python part of 2-cut optimization
parent
4a9adc94
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
group-connectivity.h
+3
-3
3 additions, 3 deletions
group-connectivity.h
groupConnectivity.pyx
+35
-2
35 additions, 2 deletions
groupConnectivity.pyx
with
38 additions
and
5 deletions
group-connectivity.h
+
3
−
3
View file @
0efdd348
...
...
@@ -158,7 +158,7 @@ struct Tester : public AbstractTester {
#endif
Mapping
&
can
n
onize
(
Mapping
&
map
)
{
Mapping
&
canonize
(
Mapping
&
map
)
{
for
(
const
auto
&
i
:
nonClassEdges
)
{
#if OPTIMIZE_COMBINE
if
(
map
[
i
.
first
]
!=
Ring
::
zero
)
...
...
@@ -225,11 +225,11 @@ struct Tester : public AbstractTester {
do
{
Mapping
copy
(
forb
);
INC
(
classes
[
pack
(
can
n
onize
(
copy
))]);
INC
(
classes
[
pack
(
canonize
(
copy
))]);
}
while
(
nextForb
(
forb
));
# else
for
(
size_t
i
=
0
;
i
<
numForb
;
i
++
)
INC
(
classes
[
pack
(
can
n
onize
(
unpack
(
i
,
forb
)))]);
INC
(
classes
[
pack
(
canonize
(
unpack
(
i
,
forb
)))]);
# endif
for
(
const
auto
&
c
:
classes
)
if
(
!
c
)
return
(
isConnected
=
false
);
...
...
This diff is collapsed.
Click to expand it.
groupConnectivity.pyx
+
35
−
2
View file @
0efdd348
...
...
@@ -25,6 +25,7 @@ cdef extern from "group-connectivity.h":
cdef
cppclass
Tester
[
T
](
AbstractTester
):
pass
def
pathToEdges
(
G
,
path
):
ret
=
[]
u
=
path
[
0
]
...
...
@@ -35,7 +36,9 @@ def pathToEdges(G, path):
u
=
v
return
ret
def
testGroupConnectivity
(
G
,
group
=
"
Z4
"
,
getClasses
=
False
,
debug
=
False
):
def
testGroupConnectivity
(
G
,
group
=
"
Z4
"
,
getClasses
=
False
,
useTwoCuts
=
False
,
debug
=
False
):
cdef
AbstractTester
*
tester
=
NULL
if
group
==
"
Z4
"
:
tester
=
new
Tester
[
Z4
[
int
]]()
...
...
@@ -46,6 +49,9 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False, debug = False):
assert
(
tester
!=
NULL
)
if
useTwoCuts
:
G
.
relabel
()
i
=
1
for
(
u
,
v
,
_
)
in
G
.
edge_iterator
():
G
.
set_edge_label
(
u
,
v
,
i
)
...
...
@@ -59,11 +65,37 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False, debug = False):
spanningTreeEdges
=
[
l
for
(
_
,
_
,
l
)
in
spanningTree
.
edge_iterator
()
]
twoCuts
=
[]
if
useTwoCuts
:
availableEdges
=
set
(
spanningTreeEdges
)
for
v
in
[
v
for
v
in
G
.
vertices
()
if
G
.
degree
(
v
)
==
2
]:
e
,
f
=
G
.
edges_incident
(
v
)
el
=
e
[
2
]
fl
=
f
[
2
]
if
el
not
in
availableEdges
or
fl
not
in
availableEdges
:
continue
availableEdges
.
remove
(
el
)
availableEdges
.
remove
(
fl
)
w1
=
e
[
0
]
if
e
[
0
]
!=
v
else
e
[
1
]
w2
=
f
[
0
]
if
f
[
0
]
!=
v
else
f
[
1
]
if
w1
>
v
:
el
*=
-
1
if
w2
<
v
:
fl
*=
-
1
if
debug
:
print
"
twoCut>
"
,
v
,
w1
,
w2
,
el
,
fl
,
(
w1
>
v
),
(
w2
<
v
)
twoCuts
.
append
((
el
,
fl
))
if
debug
:
print
"
Spanning Tree:
"
,
spanningTreeEdges
print
"
Elementary cycles:
"
,
elemCycles
print
"
Two cuts:
"
,
twoCuts
tester
.
init
(
G
.
num_edges
(),
spanningTreeEdges
,
[]
,
elemCycles
)
tester
.
init
(
G
.
num_edges
(),
spanningTreeEdges
,
twoCuts
,
elemCycles
)
ret
=
tester
.
run
()
if
getClasses
:
...
...
@@ -74,6 +106,7 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False, debug = False):
del
tester
return
ret
def
subdivisionIterator
(
G
,
edges
=
None
):
if
edges
is
None
:
edges
=
G
.
edges
()
...
...
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