Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 43 additions & 19 deletions src/sage/graphs/generators/distance_regular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -488,34 +488,58 @@
EXAMPLES::

sage: # long time, needs sage.modules sage.rings.finite_rings
sage: G = graphs.shortened_000_111_extended_binary_Golay_code_graph() # 25 s
sage: G = graphs.shortened_000_111_extended_binary_Golay_code_graph()

Check failure on line 491 in src/sage/graphs/generators/distance_regular.pyx

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.graphs.generators.distance_regular.shortened_000_111_extended_binary_Golay_code_graph[0]>", line 1, in <module> G = graphs.shortened_000_111_extended_binary_Golay_code_graph() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "sage/graphs/generators/distance_regular.pyx", line 520, in sage.graphs.generators.distance_regular.shortened_000_111_extended_binary_Golay_code_graph File "/usr/lib/python3.12/importlib/resources/_common.py", line 46, in wrapper return func(anchor) ^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/resources/_common.py", line 56, in files return from_package(resolve(anchor)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/resources/_common.py", line 113, in from_package reader = spec.loader.get_resource_reader(spec.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/resources/_adapters.py", line 29, in get_resource_reader return CompatibilityFiles(self.spec)._native() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/resources/_adapters.py", line 153, in _native reader = self._reader ^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/resources/_adapters.py", line 147, in _reader return self.spec.loader.get_resource_reader(self.spec.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap_external>", line 1425, in get_resource_reader File "/usr/lib/python3.12/importlib/resources/readers.py", line 133, in __init__ self.path = MultiplexedPath(*list(namespace_path)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/resources/readers.py", line 70, in __init__ raise NotADirectoryError('MultiplexedPath only supports directories') NotADirectoryError: MultiplexedPath only supports directories
sage: G.is_distance_regular(True)

Check failure on line 492 in src/sage/graphs/generators/distance_regular.pyx

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.graphs.generators.distance_regular.shortened_000_111_extended_binary_Golay_code_graph[1]>", line 1, in <module> G.is_distance_regular(True) ^ NameError: name 'G' is not defined
([21, 20, 16, 9, 2, 1, None], [None, 1, 2, 3, 16, 20, 21])

ALGORITHM:

Compute the extended binary Golay code. Compute its subcode whose codewords
start with 000 or 111. Remove the first 3 entries from all the codewords
from the new linear code and compute its coset graph.
The vertices and edges of this graph have been precomputed and
pickled, so truthfully, we just unpickle them and pass them to the
Graph constructor. But the algorithm used to compute those
vertices and edges in the first place is,

REFERENCES:

Description and construction of this graph can be found in [BCN1989]_ p. 365.
"""
from sage.coding.linear_code import LinearCode

code = codes.GolayCode(GF(2))
C_basis = code.basis()
#. Compute the extended binary Golay code.
#. Compute its subcode whose codewords start with 000 or 111.
#. Remove the first 3 entries from all the codewords from the
new linear code and compute its coset graph.

# now special shortening
v = C_basis[0] + C_basis[1] + C_basis[2] # v has 111 at the start
C_basis = C_basis[3:]
C_basis.append(v)
C_basis = list(map(lambda x: x[3:], C_basis))
This construction is tested in ``generators_test.py``, where the
result is compared with the result from this method.

code = LinearCode(Matrix(GF(2), C_basis))
REFERENCES:

G = code.cosetGraph()
The description and construction of this graph can be found in
[BCN1989]_, page 365.
"""
import lzma
from importlib.resources import as_file, files
from pickle import load

# Path to the pickled-and-xz'd list of (vertices, edges)
ppath = files('sage.graphs.generators').joinpath(
"shortened_000_111_extended_binary_Golay_code_graph.pickle.xz"
)

with as_file(ppath) as p:
with lzma.open(p) as f:
vs_and_es = load(f, fix_imports=False)

# Vertices/edges are pickled as tuples of ints, but should be
# vectors with entries in GF(2).
V = VectorSpace(GF(2), 21)
for i in range(2048):
# vertex i
vs_and_es[0][i] = V(vs_and_es[0][i])
vs_and_es[0][i].set_immutable()
for i in range(21504):
# edge i = (v1, v2, l)
vs_and_es[1][i][0] = V(vs_and_es[1][i][0]) # v1
vs_and_es[1][i][0].set_immutable()
vs_and_es[1][i][1] = V(vs_and_es[1][i][1]) # v2
vs_and_es[1][i][1].set_immutable()

G = Graph(vs_and_es, format='vertices_and_edges')
G.name("Shortened 000 111 extended binary Golay code")
return G

Expand Down Expand Up @@ -1100,7 +1124,7 @@
TESTS::

sage: # needs sage.modules sage.rings.finite_rings
sage: G = graphs.GrassmannGraph(2, 6, 3) # long time

Check warning on line 1127 in src/sage/graphs/generators/distance_regular.pyx

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:: Test ran for 47.38s cpu, 48.33s wall Check ran for 0.00s cpu, 0.00s wall
sage: G.is_distance_regular(True) # long time
([98, 72, 32, None], [None, 1, 9, 49])
sage: G = graphs.GrassmannGraph(3, 4, 2)
Expand Down Expand Up @@ -1162,7 +1186,7 @@
62
sage: G.is_distance_regular(True)
([6, 5, 5, None], [None, 1, 1, 6])
sage: G = graphs.DoubleGrassmannGraph(3, 2) # long time # needs sage.rings.finite_rings

Check warning on line 1189 in src/sage/graphs/generators/distance_regular.pyx

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:: Test ran for 41.25s cpu, 41.69s wall Check ran for 0.00s cpu, 0.00s wall
sage: G.order() # long time # needs sage.rings.finite_rings
2420
sage: G.is_distance_regular(True) # long time # needs sage.rings.finite_rings
Expand Down Expand Up @@ -2147,7 +2171,7 @@
Half 4 Cube: Graph on 8 vertices
sage: graph_with_classical_parameters(3, 2, 0, 2, 9) # needs sage.libs.gap
Symplectic Dual Polar Graph DSp(6, 2): Graph on 135 vertices
sage: graph_with_classical_parameters(3, 2, 2, 14, 7) # long time # needs sage.symbolic

Check warning on line 2174 in src/sage/graphs/generators/distance_regular.pyx

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[g-o]*)

Warning: slow doctest:

slow doctest:: Test ran for 52.23s cpu, 52.48s wall Check ran for 0.00s cpu, 0.00s wall
Grassmann graph J_2(6, 3): Graph on 1395 vertices
sage: graph_with_classical_parameters(3, -2, -2, 6, 6) # optional - gap_package_atlasrep internet
Generalised hexagon of order (2, 8): Graph on 819 vertices
Expand Down
34 changes: 34 additions & 0 deletions src/sage/graphs/generators/generators_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest


def test_shortened_000_111_extended_binary_Golay_code_graph():
r"""
Test that Sage produces a graph equal to the one that we get
from this construction.

The construction itself takes a long time.
"""
from sage.coding import codes_catalog
from sage.coding.linear_code import LinearCode
from sage.graphs.generators.distance_regular import (
shortened_000_111_extended_binary_Golay_code_graph
)
from sage.matrix.constructor import matrix
from sage.rings.finite_rings.finite_field_constructor import FiniteField

code = codes_catalog.GolayCode(FiniteField(2))
C_basis = code.basis()

# now special shortening
v = C_basis[0] + C_basis[1] + C_basis[2] # v has 111 at the start
C_basis = C_basis[3:]
C_basis.append(v)
C_basis = list(map(lambda x: x[3:], C_basis))

code = LinearCode(matrix(FiniteField(2), C_basis))
G = code.cosetGraph()
G.name("Shortened 000 111 extended binary Golay code")
assert G.is_distance_regular()

H = shortened_000_111_extended_binary_Golay_code_graph()
assert G == H
2 changes: 2 additions & 0 deletions src/sage/graphs/generators/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ py.install_sources(
'classical_geometries.py',
'degree_sequence.py',
'families.py',
'generators_test.py',
'intersection.py',
'platonic_solids.py',
'random.py',
'shortened_000_111_extended_binary_Golay_code_graph.pickle.xz',
'smallgraphs.py',
'world_map.py',
subdir: 'sage/graphs/generators',
Expand Down
Binary file not shown.
Loading