Skip to content

Commit

Permalink
Add construction of strongly regular digraph
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCati committed Feb 9, 2023
1 parent 104dde9 commit 8e6d6b1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
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 @@ -2174,6 +2174,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=f'Strongly regular digraph')

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

0 comments on commit 8e6d6b1

Please sign in to comment.