Skip to content

Commit db9104a

Browse files
committed
src/sage/graphs/generators: add Golay code graph pytests
The algorithm to construct the Shortened 000 111 extended binary Golay code graph takes a long time, and we plan to cache its vertices and edges. To ensure that the cached data continue to agree with the construction, we add a new pytest file that checks the two for isomorphism.
1 parent cb03043 commit db9104a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pytest
2+
3+
def test_shortened_000_111_extended_binary_Golay_code_graph():
4+
r"""
5+
Test that Sage produces a graph isomorphic to the one that we
6+
get from this construction.
7+
8+
The construction itself takes a long time.
9+
"""
10+
from sage.coding import codes_catalog
11+
from sage.coding.linear_code import LinearCode
12+
from sage.graphs.generators.distance_regular import (
13+
shortened_000_111_extended_binary_Golay_code_graph
14+
)
15+
from sage.matrix.constructor import matrix
16+
from sage.rings.finite_rings.finite_field_constructor import FiniteField
17+
18+
code = codes_catalog.GolayCode(FiniteField(2))
19+
C_basis = code.basis()
20+
21+
# now special shortening
22+
v = C_basis[0] + C_basis[1] + C_basis[2] # v has 111 at the start
23+
C_basis = C_basis[3:]
24+
C_basis.append(v)
25+
C_basis = list(map(lambda x: x[3:], C_basis))
26+
27+
code = LinearCode(matrix(FiniteField(2), C_basis))
28+
G = code.cosetGraph()
29+
G.name("Shortened 000 111 extended binary Golay code")
30+
assert G.is_distance_regular()
31+
32+
H = shortened_000_111_extended_binary_Golay_code_graph()
33+
assert G.is_isomorphic(H)

src/sage/graphs/generators/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ py.install_sources(
66
'classical_geometries.py',
77
'degree_sequence.py',
88
'families.py',
9+
'generators_test.py',
910
'intersection.py',
1011
'platonic_solids.py',
1112
'random.py',

0 commit comments

Comments
 (0)