Ticket #13058: trac_13058-all.patch

File trac_13058-all.patch, 8.2 KB (added by ncohen, 7 years ago)
  • sage/graphs/graph_generators.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1338284253 -7200
    # Node ID b47e6768c3d1375600f85259483c5b4f1a68b92b
    # Parent  9f740c3ee641e22730b6170c374260cbccdfe773
    HallJanko graph constructor
    
    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    115115- :meth:`GoldnerHararyGraph <GraphGenerators.GoldnerHararyGraph>`
    116116- :meth:`GrayGraph <GraphGenerators.GrayGraph>`
    117117- :meth:`GrotzschGraph <GraphGenerators.GrotzschGraph>`
     118- :meth:`HallJankoGraph <GraphGenerators.HallJankoGraph>`
    118119- :meth:`HararyGraph <GraphGenerators.HararyGraph>`
    119120- :meth:`HarriesGraph <GraphGenerators.HarriesGraph>`
    120121- :meth:`HarriesWongGraph <GraphGenerators.HarriesWongGraph>`
     
    15081509
    15091510        return H
    15101511
     1512    def HallJankoGraph(self, from_string=True):
     1513        r"""
     1514        Returns the Hall-Janko graph.
     1515
     1516        For more information on the Hall-Janko graph, see its
     1517        :wikipedia:`Wikipedia page <Hall-Janko_graph>`.
     1518
     1519        The construction used to generate this graph in Sage is by
     1520        a 100-point permutation representation of the Janko group `J_2`,
     1521        as described in version 3 of the ATLAS of Finite Group
     1522        representations, in particular on the page `ATLAS: J2
     1523        — Permutation representation on 100 points
     1524        <http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0>`_.
     1525
     1526        INPUT:
     1527
     1528        - ``from_string`` (boolean) -- whether to build the graph from
     1529          its sparse6 string or through GAP. The two methods return the
     1530          same graph though doing it through GAP takes more time. It is
     1531          set to ``True`` by default.
     1532
     1533        EXAMPLES::
     1534
     1535            sage: g = graphs.HallJankoGraph()
     1536            sage: g.is_regular(36)
     1537            True
     1538            sage: g.is_vertex_transitive()
     1539            True
     1540
     1541        Is it really strongly regular with parameters 14, 12? ::
     1542
     1543            sage: nu = set(g.neighbors(0))
     1544            sage: for v in range(1, 100):
     1545            ...     if v in nu:
     1546            ...        expected = 14
     1547            ...     else:
     1548            ...        expected = 12
     1549            ...     nv = set(g.neighbors(v))
     1550            ...     nv.discard(0)
     1551            ...     if len(nu & nv) != expected:
     1552            ...        print "Something is wrong here!!!"
     1553            ...        break
     1554
     1555        Some other properties that we know how to check::
     1556
     1557            sage: g.diameter()
     1558            2
     1559            sage: g.girth()
     1560            3
     1561            sage: factor(g.characteristic_polynomial())
     1562            (x - 36) * (x - 6)^36 * (x + 4)^63
     1563
     1564        TESTS::
     1565
     1566            sage: gg = graphs.HallJankoGraph(from_string=False) # long time
     1567            sage: g == gg # long time
     1568            True
     1569        """
     1570
     1571        string = (":~?@c__E@?g?A?w?A@GCA_?CA`OWF`W?EAW?@?_OD@_[GAgcIaGGB@OcIA"
     1572                  "wCE@o_K_?GB@?WGAouC@OsN_?GB@O[GB`A@@_e?@OgLB_{Q_?GC@O[GAOs"
     1573                  "OCWGBA?kKBPA@?_[KB_{OCPKT`o_RD`]A?o[HBOwODW?DA?cIB?wRDP[X`"
     1574                  "ogKB_{QD@]B@o_KBPWXE`mC@o_JB?{PDPq@?oWGA_{OCPKTDp_YEwCA@_c"
     1575                  "IBOwOC`OX_OGB@?WPDPcYFg?C@_gKBp?SE@cYF`{_`?SGAOoOC`_\\FwCE"
     1576                  "A?gKBO{QD@k[FqI??_OFA_oQE@k\\Fq?`GgCB@pGRD@_XFP{a_?SE@ocIA"
     1577                  "ooNCPOUEqU@?oODA?cJB_{UEqYC@_kLC@CREPk]GAGbHgCA@?SMBpCSD`["
     1578                  "YFq?`Ga]BA?gPC`KSD`_\\Fa?cHWGB@?[IAooPD`[WF@s^HASeIg?@@OcP"
     1579                  "C`KYF@w^GQ[h`O[HAooMC@CQCpSVEPk\\GaSeIG?FA?kLB_{OC`OVE@cYG"
     1580                  "QUA@?WLBp?PC`KVEqKgJg?DA?sMBpCSDP[WEQKfIay@?_KD@_[GC`SUE@k"
     1581                  "[FaKdHa[k_?OLC@CRD@WVEpo^HAWfIAciIqoo_?CB@?kMCpOUE`o\\GAKg"
     1582                  "IQgq_?GD@_[GB?{OCpWVE@cYFACaHAWhJR?q_?CC@_kKBpC\\GACdHa[kJ"
     1583                  "a{o_?CA?oOFBpGRD@o\\GaKdIQonKrOt_?WHA`?PC`KTD`k]FqSeIaolJr"
     1584                  "CqLWCA@OkKCPGRDpcYGAKdIAgjJAsmJr?t__OE@ogJB_{XEps`HA[gIQwn"
     1585                  "KWKGAOoMBpGUE`k[Fa?aHqckJbSuLw?@?_SHA_kLC@OTFPw^GaOkLg?B@?"
     1586                  "[HA_{PDP_XFaCbHa[gIqooKRWx_?CFBpOTE@cZFPw^GACcHQgoKrSvMwWG"
     1587                  "BOwQCp_YFP{`HASfJAwnKRSx_OSSDP[WEq?aGqSfIQsoKR_zNWCE@o_HA_"
     1588                  "sREPg^GAGcHQWfIAciKbOxNg?A@__IAooMC`KTD`g\\GAKcIasoKrOtLb["
     1589                  "wMbyCA?cKBp?TD`[WE`s^GQGbHqcjJrK{NRw~_oODA?sNC@CQCpOZF@s]G"
     1590                  "QOfIaolJrGsLbk}_?OFA_sRD@SVE`k[HQcjJa{qLb[xMb|?_OOFA?cIAos"
     1591                  "RDP_ZFa?aGqOfIAsuMbk{Ns@@OsQAA_sPDPWXE`o\\FqKdIQkkJrCuLr_x"
     1592                  "Mro}NsDAPG?@@OWFApKUE@o`IQolKRKsLrc|NsQC@OWGAOgJCpOWE`o_GQ"
     1593                  "KiIqwnKr_~OcLCPS]A?oWHA_oMBpKSDP[\\FagjKBWxMbk{OSQ@@O_IAoo"
     1594                  "LBpCSD`g\\FaGbHQWgIQgmKRKwMRl?PgGC@OWHB@KSE@c[FqCaGqSeIAkk"
     1595                  "KBCqLBSuMBpGQWCA@?cKBOwRDPWVE@k^GqOfJr?pKbKtLrs}OSHDQwKIBO"
     1596                  "wPD@WWEQ?`HQWfIQglKBOtLbo}Ns@@OsTE_?kLCpWWHA[gIqomKBGwMRgz"
     1597                  "NBw~OSPDPc\\H_?CFAOoLCPSVE`o\\GAOeJAwpKbKtMrx?Qcq??OKFA?gJ"
     1598                  "B`?QDpcYEpo]FqKfIAgjJB?qKr_{NS@A__SE@o_HBO{PC`OTD`{_HaciIq"
     1599                  "{vMbt?OcPFQCeB@?SKBOwRD@SXE`k[FPw`HQ_lKRKxNRxBPC\\HQclK_?K"
     1600                  "EB?sOC`OTDa?`GqWgJRCrNBw~OSHFQStMRtDQ_?KC@OoQE`k_GaOdHa[gI"
     1601                  "q{tMBg|Nb|?OcPMSDDQSwCB@_cJB_{OCpOVFP{dHa[jJQwqKrk}NsHBQCd"
     1602                  "MRtMA?oSEA_wPDp_YEpo]GAOeIq{pLBk}NsLEQCtNTDU??OKEA_oLC@[[G"
     1603                  "aKnKBOtLbk~OCPFQStNSDLSTgGKC@GSD`[WEpw_GQGcIAciJAwpKb_xMbk"
     1604                  "~QShJRc|R`_wNCPcZF@s^GAGbHA_hJR?qKrOvMRg|NsDEPsxTTgCB@?gJB"
     1605                  "?sMC@CUDp_]FqCaHQcjJQwtLrhCPS\\IRCtQTw?B@?SHA_wPC`_aGqOiJa"
     1606                  "{oKRKvMRpFQChKRtXVUTi??ocNC@KUE@cYFaGdHa_mJrKsLb[yMro|OcXI"
     1607                  "RdPTTddZaOgJB@?UEPk[FQCfIaolJrSvMBczNR|AOsXFQCtOTtaB@?WGAP"
     1608                  "?TEPo\\GAGdHqgmKBCqLR[xMb|?PC`HQs|TTt`XUtu@?o[HB?sNCPGXF@{"
     1609                  "_GQKcIqolJb_yNCLDPs`MRtDRTTdYUwSEA?kLB`CWF@s]FqGgIqooLRgzN"
     1610                  "RxFQSlMSDDQTDXVUTi@?_KDAOoLBpKUEQOfIa{oLB_xMrt?Os\\HQcpMST"
     1611                  "HSTtl[VT}A@ocJBOwSD`_XEpo_Ha_mJrKtLbgzNSTGQspLRtDUUDp\\WG["
     1612                  "HB`CQCp[WFQGgIQgkJQ{rLbc{Nc@APsdLRt@PSt\\WUtt_Wn")
     1613
     1614        if from_string:
     1615            g = graph.Graph(string, loops = False, multiedges = False)
     1616        else:
     1617
     1618            # The following construction is due to version 3 of the ATLAS of
     1619            # Finite Group Representations, specifically the page at
     1620            # http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0 .
     1621
     1622            from sage.interfaces.gap import gap
     1623            gap.eval("g1 := (1,84)(2,20)(3,48)(4,56)(5,82)(6,67)(7,55)(8,41)"
     1624                     "(9,35)(10,40)(11,78)(12,100)(13,49)(14,37)(15,94)(16,76)"
     1625                     "(17,19)(18,44)(21,34)(22,85)(23,92)(24,57)(25,75)(26,28)"
     1626                     "(27,64)(29,90)(30,97)(31,38)(32,68)(33,69)(36,53)(39,61)"
     1627                     "(42,73)(43,91)(45,86)(46,81)(47,89)(50,93)(51,96)(52,72)"
     1628                     "(54,74)(58,99)(59,95)(60,63)(62,83)(65,70)(66,88)(71,87)"
     1629                     "(77,98)(79,80);")
     1630
     1631            gap.eval("g2 := (1,80,22)(2,9,11)(3,53,87)(4,23,78)(5,51,18)"
     1632                     "(6,37,24)(8,27,60)(10,62,47)(12,65,31)(13,64,19)"
     1633                     "(14,61,52)(15,98,25)(16,73,32)(17,39,33)(20,97,58)"
     1634                     "(21,96,67)(26,93,99)(28,57,35)(29,71,55)(30,69,45)"
     1635                     "(34,86,82)(38,59,94)(40,43,91)(42,68,44)(46,85,89)"
     1636                     "(48,76,90)(49,92,77)(50,66,88)(54,95,56)(63,74,72)"
     1637                     "(70,81,75)(79,100,83);")
     1638
     1639            gap.eval("G := Group([g1,g2]);")
     1640            edges = gap('Orbit(G,[1,5],OnSets)').sage()
     1641            g = graph.Graph([(int(u), int(v)) for u,v in edges])
     1642            g.relabel()
     1643
     1644        _circle_embedding(g, range(100))
     1645        g.name("Hall-Janko graph")
     1646        return g
     1647
    15111648    def HararyGraph( self, k, n ):
    15121649        r"""
    15131650        Returns the Harary graph on `n` vertices and connectivity `k`, where
     
    87418878    c_x, c_y = center
    87428879    n = len(vertices)
    87438880    d = g.get_pos()
     8881    if d is None:
     8882        d = {}
    87448883
    87458884    for i,v in enumerate(vertices):
    87468885        i += shift
     
    87738912    dy = (last[1] - first[1])/n
    87748913
    87758914    d = g.get_pos()
     8915    if d is None:
     8916        d = {}
     8917
    87768918    for v in vertices:
    87778919        d[v] = (fx, fy)
    87788920        fx += dx