Skip to content

Commit

Permalink
gh-pr-34986: Add construction of strongly regular digraph
Browse files Browse the repository at this point in the history
Fixes #24682.

URL: #34986
Reported by: MatteoCati
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Feb 19, 2023
2 parents da48f14 + 5bd750c commit 08185d7
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 4 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=52318f4340fa311efa518fc82ad6458b2922415f
md5=6c3a20cfb9bd47cd59f09b2ca2dad664
cksum=2889014807
sha1=2157b8350185e5af083a1655cb574f9a3e18f3cc
md5=06742724b290cd62cc86d4be498b1db9
cksum=4073009205
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d3f8a79186069e3ceb467052a468a36a521fd3eb
c3a8fdd9d4d03e0c5e73e409408735ecd498ba98
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

0 comments on commit 08185d7

Please sign in to comment.