Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add construction of strongly regular digraph #34986

Merged
merged 4 commits into from
Feb 19, 2023
Merged
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
5 changes: 5 additions & 0 deletions src/doc/en/reference/references/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,11 @@ REFERENCES:
.. [Duv1983] J.-P. Duval, Factorizing words over an ordered alphabet,
J. Algorithms 4 (1983) 363--381.

.. [Duv1988] \A. Duval.
*A directed graph version of strongly regular graphs*,
Journal of Combinatorial Theory, Series A 47(1) (1988): 71-100.
:doi:`10.1016/0097-3165(88)90043-X`

.. [DW1995] Andreas W.M. Dress and Walter Wenzel, *A Simple Proof of
an Identity Concerning Pfaffians of Skew Symmetric
Matrices*, Advances in Mathematics, volume 112, Issue 1,
Expand Down
47 changes: 47 additions & 0 deletions src/sage/graphs/digraph_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,53 @@ def Path(self, n):
g.set_pos({i: (i, 0) for i in range(n)})
return g

def StronglyRegular(self, n):
r"""
Return a Strongly Regular digraph with `n` vertices.

The adjacency matrix of the graph is constructed from a skew Hadamard
matrix of order `n+1`. These graphs were first constructed in [Duv1988]_.

INPUT:

- ``n`` -- integer, the number of vertices of the digraph.

.. SEEALSO::

- :func:`sage.combinat.matrices.hadamard_matrix.skew_hadamard_matrix`
- :meth:`Paley`

EXAMPLES:

A Strongly Regular digraph satisfies the condition `AJ = JA = kJ` where
`A` is the adjacency matrix::

sage: g = digraphs.StronglyRegular(7); g
Strongly regular digraph: Digraph on 7 vertices
sage: A = g.adjacency_matrix()*ones_matrix(7); B = ones_matrix(7)*g.adjacency_matrix()
sage: A == B == A[0, 0]*ones_matrix(7)
True

TESTS:

Wrong parameter::

sage: digraphs.StronglyRegular(73)
Traceback (most recent call last):
...
ValueError: strongly regular digraph with 73 vertices not yet implemented

"""
from sage.combinat.matrices.hadamard_matrix import skew_hadamard_matrix
from sage.matrix.constructor import ones_matrix, identity_matrix
if skew_hadamard_matrix(n + 1, existence=True) is not True:
raise ValueError(f'strongly regular digraph with {n} vertices not yet implemented')

H = skew_hadamard_matrix(n + 1, skew_normalize=True)
M = H[1:, 1:]
M = (M + ones_matrix(n)) / 2 - identity_matrix(n)
return DiGraph(M, format='adjacency_matrix', name='Strongly regular digraph')

def Paley(self, q):
r"""
Return a Paley digraph on `q` vertices.
Expand Down