Ticket #14532: trac_14532.patch

File trac_14532.patch, 3.0 KB (added by ncohen, 8 years ago)
  • sage/graphs/generators/families.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1367751119 -7200
    # Node ID e513113fdf07491381a1b0f5e82268c13b29d9ce
    # Parent  b4db5e332c582a8b104cf14494d5aeda84295792
    A constructor for symplectic graphs
    
    diff --git a/sage/graphs/generators/families.py b/sage/graphs/generators/families.py
    a b  
    19701970    g.relabel(vertices)
    19711971
    19721972    return g
     1973
     1974def SymplecticGraph(d,q):
     1975    r"""
     1976    Returns the Symplectic graph `Sp(d,q)`
     1977
     1978    The Symplectic Graph `Sp(d,q)` is built from a projective space of dimension
     1979    `d-1` over a field `F_q`, and a symplectic form `f`. Two vertices `u,v` are
     1980    made adjacent if `f(u,v)=0`.
     1981
     1982    See the `page on symplectic graphs on Andries Brouwer's website
     1983    <http://www.win.tue.nl/~aeb/graphs/Sp.html>`_.
     1984
     1985    INPUT:
     1986
     1987    - ``d,q`` (integers) -- note that only even values of `d` are accepted by
     1988      the function.
     1989
     1990    EXAMPLES::
     1991
     1992        sage: g = graphs.SymplecticGraph(6,2)
     1993        sage: g.is_strongly_regular(parameters=True)
     1994        (63, 30, 13, 15)
     1995        sage: set(g.spectrum()) == {-5, 3, 30}
     1996        True
     1997    """
     1998    from sage.rings.finite_rings.constructor import FiniteField
     1999    from sage.modules.free_module import VectorSpace
     2000    from sage.schemes.generic.projective_space import ProjectiveSpace
     2001    from sage.matrix.constructor import identity_matrix, block_matrix, zero_matrix
     2002
     2003    if d < 1 or d%2 != 0:
     2004        raise ValueError("d must be even and greater than 2")
     2005
     2006    F = FiniteField(q,"x")
     2007    M = block_matrix(F, 2, 2,
     2008                     [zero_matrix(F,d/2),
     2009                      identity_matrix(F,d/2),
     2010                      -identity_matrix(F,d/2),
     2011                      zero_matrix(F,d/2)])
     2012
     2013    V = VectorSpace(F,d)
     2014    PV = list(ProjectiveSpace(d-1,F))
     2015    G = Graph([map(tuple,PV), lambda x,y:V(x)*(M*V(y)) == 0], loops = False)
     2016    G.name("Symplectic Graph Sp("+str(d)+","+str(q)+")")
     2017    G.relabel()
     2018    return G
     2019
  • sage/graphs/graph_generators.py

    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    168168     "RingedTree",
    169169     "line_graph_forbidden_subgraphs",
    170170     "PermutationGraph",
     171     "SymplecticGraph",
    171172     "trees"])
    172173
    173174__doc__ += """
     
    943944    OddGraph               = staticmethod(sage.graphs.generators.families.OddGraph)
    944945    PaleyGraph             = staticmethod(sage.graphs.generators.families.PaleyGraph)
    945946    PermutationGraph       = staticmethod(sage.graphs.generators.families.PermutationGraph)
     947    SymplecticGraph        = staticmethod(sage.graphs.generators.families.SymplecticGraph)
    946948    HanoiTowerGraph        = staticmethod(sage.graphs.generators.families.HanoiTowerGraph)
    947949    line_graph_forbidden_subgraphs = staticmethod(sage.graphs.generators.families.line_graph_forbidden_subgraphs)
    948950    trees                  = staticmethod(sage.graphs.generators.families.trees)