# Ticket #14631: trac_14631.patch

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

```# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1369299112 -7200
# Node ID 8f6b2961be58ba292c97722f1a74803a2fdc14fa
# Parent  30f3ca60e0004bd6c7b9d4f539b5f59784326c09
Affine Polar Graphs

diff --git a/sage/graphs/generators/families.py b/sage/graphs/generators/families.py```
 a G.relabel() return G def AffinePolarGraph(d,q,sign="+"): r""" Returns the affine polar graph `VO^+(d,q),VO^-(d,q)` or `VO(d,q)`. Affine Polar graphs are built from a `d`-dimensional vector space over `F_q`, and a quadratic form which is hyperbolic, elliptic or parabolic according to the value of ``sign``. Note that `VO^+(d,q),VO^-(d,q)` are strongly regular graphs, while `VO(d,q)` is not. For more information on Affine Polar graphs, see the corresponding `page of Andries Brouwer's website `_. INPUT: - ``d`` (integer) -- ``d`` must be even if ``sign != None``, and odd otherwise. - ``q`` (integer) -- a power of a prime number, as `F_q` must exist. - ``sign`` -- must be qual to ``"+"``, ``"-"``, or ``None`` to compute (respectively) `VO^+(d,q),VO^-(d,q)` or `VO(d,q)`. By default ``sign="+"``. EXAMPLES: The :meth:`Brouwer-Haemers graph ` is isomorphic to `VO^-(4,3)`:: sage: g = graphs.AffinePolarGraph(4,3,"-") sage: g.is_isomorphic(graphs.BrouwerHaemersGraph()) True Some examples from `Brouwer's table or strongly regular graphs `_:: sage: g = graphs.AffinePolarGraph(6,2,"-"); g Affine Polar Graph VO^-(6,2): Graph on 64 vertices sage: g.is_strongly_regular(parameters=True) (64, 27, 10, 12) sage: g = graphs.AffinePolarGraph(6,2,"+"); g Affine Polar Graph VO^+(6,2): Graph on 64 vertices sage: g.is_strongly_regular(parameters=True) (64, 35, 18, 20) When ``sign is None``:: sage: g = graphs.AffinePolarGraph(5,2,None); g Affine Polar Graph VO^-(5,2): Graph on 32 vertices sage: g.is_strongly_regular(parameters=True) False sage: g.is_regular() True sage: g.is_vertex_transitive() True """ if sign in ["+","-"]: s = 1 if sign == "+" else -1 if d%2 == 1: raise ValueError("d must be even when sign!=None") else: if d%2 == 0: raise ValueError("d must be odd when sign==None") s = 0 from sage.interfaces.gap import gap from sage.rings.finite_rings.constructor import FiniteField from sage.modules.free_module import VectorSpace from sage.matrix.constructor import Matrix from itertools import combinations m = gap("InvariantQuadraticForm(GO("+str(s)+","+str(d)+","+str(q)+")).matrix") F = FiniteField(q,"x") V = list(VectorSpace(F,d)) M = [[F(y) for y in mm] for mm in m] M = Matrix(F,M) G = Graph() G.add_vertices(map(tuple,V)) for x,y in combinations(V,2): if not (x-y)*(M*(x-y)): G.add_edge(tuple(x),tuple(y)) G.name("Affine Polar Graph VO^"+str('+' if s == 1 else '-')+"("+str(d)+","+str(q)+")") G.relabel() return G
• ## sage/graphs/graph_generators.py

`diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py`
 a "line_graph_forbidden_subgraphs", "PermutationGraph", "SymplecticGraph", "AffinePolarGraph", "trees"]) __doc__ += """ PaleyGraph             = staticmethod(sage.graphs.generators.families.PaleyGraph) PermutationGraph       = staticmethod(sage.graphs.generators.families.PermutationGraph) SymplecticGraph        = staticmethod(sage.graphs.generators.families.SymplecticGraph) AffinePolarGraph       = staticmethod(sage.graphs.generators.families.AffinePolarGraph) HanoiTowerGraph        = staticmethod(sage.graphs.generators.families.HanoiTowerGraph) line_graph_forbidden_subgraphs = staticmethod(sage.graphs.generators.families.line_graph_forbidden_subgraphs) trees                  = staticmethod(sage.graphs.generators.families.trees)