Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Radek Hušek
group-connectivity-pub
Commits
beed8f40
Commit
beed8f40
authored
Jul 22, 2017
by
Radek Hušek
Browse files
groupConnectivityNaive.py: doctest
parent
e7152871
Changes
1
Hide whitespace changes
Inline
Side-by-side
groupConnectivityNaive.py
View file @
beed8f40
...
...
@@ -2,8 +2,25 @@ from sage.graphs.graph import Graph, DiGraph
from
sage.rings.finite_rings.integer_mod_ring
import
Integers
def
Zkn
(
k
,
n
):
"""Create group Z_k^n
EXAMPLES:
>>> list(Zkn(4, 1))
[0, 1, 2, 3]
>>> list(Zkn(3,2))
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
>>> list(Zkn(2,3)) # doctest: +NORMALIZE_WHITESPACE
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1),
(1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
"""
Zk
=
Integers
(
k
)
return
Zk
.
cartesian_product
(
*
([
Zk
]
*
(
n
-
1
))
)
if
n
==
1
:
return
Zk
else
:
return
Zk
.
cartesian_product
(
*
([
Zk
]
*
(
n
-
1
))
)
def
prettifyGraph
(
G_
):
"""Convert graph into directed one and number its edges."""
...
...
@@ -132,3 +149,9 @@ def myHistogram(data):
s
[
i
]
+=
1
return
s
if
__name__
==
"__main__"
:
import
doctest
ret
=
doctest
.
testmod
()
print
"%i tests of %i failed."
%
ret
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment