# Ticket #13058: trac_13058-fromstring.patch

File trac_13058-fromstring.patch, 5.2 KB (added by ncohen, 12 months ago)
• ## sage/graphs/graph_generators.py

```# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1338373600 -7200
# Node ID 1a1f98e921da153165f4774c4e66aa97a0a89a78
# Parent  e43401df8ed6360c3ac0b0db812fcd5673810c52
Two constructions for graphs.HallJankoGraph

diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py```
 a return H def HallJankoGraph(self): def HallJankoGraph(self, from_string = True): r""" Returns the Hall-Janko graph. â Permutation representation on 100 points `_. INPUT: - ``from_string`` (boolean) -- whether to build the graph from its sparse6 string or through GAP. The two methods return the same graph though doing it through GAP takes more time. It is set to ``True`` by default. EXAMPLES:: sage: g = graphs.HallJankoGraph() 3 sage: factor(g.characteristic_polynomial()) (x - 36) * (x - 6)^36 * (x + 4)^63 """ # Below are the lines generating the graph's sparse6 string. As it # takes some time to run them, this method actually builds the graph # from its sparse6 string. # The following construction is due to version 3 of the ATLAS of Finite # Group Representations, specifically the page at # http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0 . # from sage.interfaces.gap import gap # gap.eval("g1 := (1,84)(2,20)(3,48)(4,56)(5,82)(6,67)(7,55)(8,41)" #          "(9,35)(10,40)(11,78)(12,100)(13,49)(14,37)(15,94)(16,76)" #          "(17,19)(18,44)(21,34)(22,85)(23,92)(24,57)(25,75)(26,28)" #          "(27,64)(29,90)(30,97)(31,38)(32,68)(33,69)(36,53)(39,61)" #          "(42,73)(43,91)(45,86)(46,81)(47,89)(50,93)(51,96)(52,72)" #          "(54,74)(58,99)(59,95)(60,63)(62,83)(65,70)(66,88)(71,87)" #          "(77,98)(79,80);") # gap.eval("g2 := (1,80,22)(2,9,11)(3,53,87)(4,23,78)(5,51,18)" #          "(6,37,24)(8,27,60)(10,62,47)(12,65,31)(13,64,19)(14,61,52)" #          "(15,98,25)(16,73,32)(17,39,33)(20,97,58)(21,96,67)" #          "(26,93,99)(28,57,35)(29,71,55)(30,69,45)(34,86,82)" #          "(38,59,94)(40,43,91)(42,68,44)(46,85,89)(48,76,90)" #          "(49,92,77)(50,66,88)(54,95,56)(63,74,72)(70,81,75)" #          "(79,100,83);") # gap.eval("G := Group([g1,g2]);") # edges = gap('Orbit(G,[1,5],OnSets)') # edge_list = [] # for u, v in edges: #     edge_list.append((int(u),int(v))) # g = sage.graphs.graph.Graph(edge_list, pos={}) # string = g.sparse6_string() TESTS:: sage: gg = graphs.HallJankoGraph(from_string = False) sage: g == gg True """ string = (":~?@c__E@?g?A?w?A@GCA_?CA`OWF`W?EAW?@?_OD@_[GAgcIaGGB@OcIA" "wCE@o_K_?GB@?WGAouC@OsN_?GB@O[GB`A@@_e?@OgLB_{Q_?GC@O[GAOs" "HSTtl[VT}A@ocJBOwSD`_XEpo_Ha_mJrKtLbgzNSTGQspLRtDUUDp\\WG[" "HB`CQCp[WFQGgIQgkJQ{rLbc{Nc@APsdLRt@PSt\\WUtt_Wn") g = graph.Graph(string, pos={}, loops=False, multiedges=False) if from_string: g = graph.Graph(string, pos={}, loops=False, multiedges=False) else: # The following construction is due to version 3 of the ATLAS of Finite # Group Representations, specifically the page at # http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0 . from sage.interfaces.gap import gap gap.eval("g1 := (1,84)(2,20)(3,48)(4,56)(5,82)(6,67)(7,55)(8,41)" "(9,35)(10,40)(11,78)(12,100)(13,49)(14,37)(15,94)(16,76)" "(17,19)(18,44)(21,34)(22,85)(23,92)(24,57)(25,75)(26,28)" "(27,64)(29,90)(30,97)(31,38)(32,68)(33,69)(36,53)(39,61)" "(42,73)(43,91)(45,86)(46,81)(47,89)(50,93)(51,96)(52,72)" "(54,74)(58,99)(59,95)(60,63)(62,83)(65,70)(66,88)(71,87)" "(77,98)(79,80);") gap.eval("g2 := (1,80,22)(2,9,11)(3,53,87)(4,23,78)(5,51,18)" "(6,37,24)(8,27,60)(10,62,47)(12,65,31)(13,64,19)(14,61,52)" "(15,98,25)(16,73,32)(17,39,33)(20,97,58)(21,96,67)" "(26,93,99)(28,57,35)(29,71,55)(30,69,45)(34,86,82)" "(38,59,94)(40,43,91)(42,68,44)(46,85,89)(48,76,90)" "(49,92,77)(50,66,88)(54,95,56)(63,74,72)(70,81,75)" "(79,100,83);") gap.eval("G := Group([g1,g2]);") edges = gap('Orbit(G,[1,5],OnSets)') edge_list = [] for u, v in edges: edge_list.append((int(u),int(v))) g = graph.Graph(edge_list, pos={}) g.relabel() _circle_embedding(g, range(100)) g.name("Hall-Janko graph")