Ticket #13058: trac_13058-fromstring.patch

File trac_13058-fromstring.patch, 5.2 KB (added by ncohen, 7 years 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 b  
    15111511
    15121512        return H
    15131513
    1514     def HallJankoGraph(self):
     1514    def HallJankoGraph(self, from_string = True):
    15151515        r"""
    15161516        Returns the Hall-Janko graph.
    15171517
     
    15251525        — Permutation representation on 100 points
    15261526        <http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0>`_.
    15271527
     1528        INPUT:
     1529
     1530        - ``from_string`` (boolean) -- whether to build the graph from
     1531          its sparse6 string or through GAP. The two methods return the
     1532          same graph though doing it through GAP takes more time. It is
     1533          set to ``True`` by default.
     1534
    15281535        EXAMPLES::
    15291536
    15301537            sage: g = graphs.HallJankoGraph()
     
    15551562            3
    15561563            sage: factor(g.characteristic_polynomial())
    15571564            (x - 36) * (x - 6)^36 * (x + 4)^63
    1558         """
    1559         # Below are the lines generating the graph's sparse6 string. As it
    1560         # takes some time to run them, this method actually builds the graph
    1561         # from its sparse6 string.
    1562 
    1563         # The following construction is due to version 3 of the ATLAS of Finite
    1564         # Group Representations, specifically the page at
    1565         # http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0 .
    1566 
    1567         # from sage.interfaces.gap import gap
    1568         # gap.eval("g1 := (1,84)(2,20)(3,48)(4,56)(5,82)(6,67)(7,55)(8,41)"
    1569         #          "(9,35)(10,40)(11,78)(12,100)(13,49)(14,37)(15,94)(16,76)"
    1570         #          "(17,19)(18,44)(21,34)(22,85)(23,92)(24,57)(25,75)(26,28)"
    1571         #          "(27,64)(29,90)(30,97)(31,38)(32,68)(33,69)(36,53)(39,61)"
    1572         #          "(42,73)(43,91)(45,86)(46,81)(47,89)(50,93)(51,96)(52,72)"
    1573         #          "(54,74)(58,99)(59,95)(60,63)(62,83)(65,70)(66,88)(71,87)"
    1574         #          "(77,98)(79,80);")
    1575 
    1576         # gap.eval("g2 := (1,80,22)(2,9,11)(3,53,87)(4,23,78)(5,51,18)"
    1577         #          "(6,37,24)(8,27,60)(10,62,47)(12,65,31)(13,64,19)(14,61,52)"
    1578         #          "(15,98,25)(16,73,32)(17,39,33)(20,97,58)(21,96,67)"
    1579         #          "(26,93,99)(28,57,35)(29,71,55)(30,69,45)(34,86,82)"
    1580         #          "(38,59,94)(40,43,91)(42,68,44)(46,85,89)(48,76,90)"
    1581         #          "(49,92,77)(50,66,88)(54,95,56)(63,74,72)(70,81,75)"
    1582         #          "(79,100,83);")
    1583 
    1584         # gap.eval("G := Group([g1,g2]);")
    1585         # edges = gap('Orbit(G,[1,5],OnSets)')
    1586 
    1587         # edge_list = []
    1588         # for u, v in edges:
    1589         #     edge_list.append((int(u),int(v)))
    1590 
    1591         # g = sage.graphs.graph.Graph(edge_list, pos={})
    1592         # string = g.sparse6_string()
     1565
     1566        TESTS::
     1567
     1568            sage: gg = graphs.HallJankoGraph(from_string = False)
     1569            sage: g == gg
     1570            True
     1571        """
    15931572
    15941573        string = (":~?@c__E@?g?A?w?A@GCA_?CA`OWF`W?EAW?@?_OD@_[GAgcIaGGB@OcIA"
    15951574                  "wCE@o_K_?GB@?WGAouC@OsN_?GB@O[GB`A@@_e?@OgLB_{Q_?GC@O[GAOs"
     
    16341613                  "HSTtl[VT}A@ocJBOwSD`_XEpo_Ha_mJrKtLbgzNSTGQspLRtDUUDp\\WG["
    16351614                  "HB`CQCp[WFQGgIQgkJQ{rLbc{Nc@APsdLRt@PSt\\WUtt_Wn")
    16361615
    1637         g = graph.Graph(string, pos={}, loops=False, multiedges=False)
     1616        if from_string:
     1617            g = graph.Graph(string, pos={}, loops=False, multiedges=False)
     1618        else:
     1619
     1620            # The following construction is due to version 3 of the ATLAS of Finite
     1621            # Group Representations, specifically the page at
     1622            # http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0 .
     1623
     1624            from sage.interfaces.gap import gap
     1625            gap.eval("g1 := (1,84)(2,20)(3,48)(4,56)(5,82)(6,67)(7,55)(8,41)"
     1626                     "(9,35)(10,40)(11,78)(12,100)(13,49)(14,37)(15,94)(16,76)"
     1627                     "(17,19)(18,44)(21,34)(22,85)(23,92)(24,57)(25,75)(26,28)"
     1628                     "(27,64)(29,90)(30,97)(31,38)(32,68)(33,69)(36,53)(39,61)"
     1629                     "(42,73)(43,91)(45,86)(46,81)(47,89)(50,93)(51,96)(52,72)"
     1630                     "(54,74)(58,99)(59,95)(60,63)(62,83)(65,70)(66,88)(71,87)"
     1631                     "(77,98)(79,80);")
     1632
     1633            gap.eval("g2 := (1,80,22)(2,9,11)(3,53,87)(4,23,78)(5,51,18)"
     1634                     "(6,37,24)(8,27,60)(10,62,47)(12,65,31)(13,64,19)(14,61,52)"
     1635                     "(15,98,25)(16,73,32)(17,39,33)(20,97,58)(21,96,67)"
     1636                     "(26,93,99)(28,57,35)(29,71,55)(30,69,45)(34,86,82)"
     1637                     "(38,59,94)(40,43,91)(42,68,44)(46,85,89)(48,76,90)"
     1638                     "(49,92,77)(50,66,88)(54,95,56)(63,74,72)(70,81,75)"
     1639                     "(79,100,83);")
     1640
     1641            gap.eval("G := Group([g1,g2]);")
     1642            edges = gap('Orbit(G,[1,5],OnSets)')
     1643
     1644            edge_list = []
     1645            for u, v in edges:
     1646                edge_list.append((int(u),int(v)))
     1647
     1648            g = graph.Graph(edge_list, pos={})
     1649            g.relabel()
    16381650
    16391651        _circle_embedding(g, range(100))
    16401652        g.name("Hall-Janko graph")