Ticket #12989: trac_12989.patch

File trac_12989.patch, 6.5 KB (added by ncohen, 7 years ago)
  • sage/graphs/graph_generators.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1337686752 -7200
    # Node ID 37a33d21f67e85e7a4c40b9ad7fa68d169aa184f
    # Parent  0f8b02e0598f3b9ee21c00f0d0a87a1d4cfb2fb7
    Ellingham-Horton graphs to Sage's database
    
    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    105105- :meth:`DesarguesGraph <GraphGenerators.DesarguesGraph>`
    106106- :meth:`DurerGraph <GraphGenerators.DurerGraph>`
    107107- :meth:`DyckGraph <GraphGenerators.DyckGraph>`
     108- :meth:`EllinghamHorton54Graph <GraphGenerators.EllinghamHorton54Graph>`
     109- :meth:`EllinghamHorton78Graph <GraphGenerators.EllinghamHorton78Graph>`
    108110- :meth:`ErreraGraph <GraphGenerators.ErreraGraph>`
    109111- :meth:`FlowerSnark <GraphGenerators.FlowerSnark>`
    110112- :meth:`FosterGraph <GraphGenerators.FosterGraph>`
     
    33733375
    33743376        return graph.Graph(edge_dict, pos=pos_dict, name="Dyck graph")
    33753377
     3378    def EllinghamHorton54Graph(self):
     3379        r"""
     3380        Returns the Ellingham-Horton 54-graph.
     3381
     3382        For more information, see the :wikipedia:`Wikipedia page on the
     3383        Ellingham-Horton graphs
     3384        <http://en.wikipedia.org/wiki/Ellingham%E2%80%93Horton_graph>`
     3385
     3386        EXAMPLE:
     3387
     3388        This graph is 3-regular::
     3389
     3390            sage: g = graphs.EllinghamHorton54Graph()
     3391            sage: g.is_regular(k=3)
     3392            True
     3393
     3394        It is 3-connected and bipartite::
     3395
     3396            sage: g.vertex_connectivity() # not tested - too long
     3397            3
     3398            sage: g.is_bipartite()
     3399            True
     3400
     3401        It is not Hamiltonian::
     3402
     3403            sage: g.is_hamiltonian() # not tested - too long
     3404            False
     3405
     3406        ... and it has a nice drawing ::
     3407
     3408            sage: g.show(figsize=[10,10]) # not tested - too long
     3409
     3410        TESTS::
     3411
     3412            sage: g.show() # long time
     3413        """
     3414        up = graphs.CycleGraph(16)
     3415        low = 2*graphs.CycleGraph(6)
     3416
     3417        for v in range(6):
     3418            low.add_edge(v, v+12)
     3419            low.add_edge(v+6, v+12)
     3420        low.add_edge(12,15)
     3421        low.delete_edge(1,2)
     3422        low.delete_edge(8,7)
     3423        low.add_edge(1,8)
     3424        low.add_edge(7,2)
     3425
     3426        # The set of vertices on top is 0..15
     3427        # Bottom left is 16..33
     3428        # Bottom right is 34..52
     3429        # The two other vertices are 53, 54
     3430        g = up + 2*low
     3431        g.name("Ellingham-Horton 54 graph.")
     3432        g.set_pos({})
     3433
     3434        g.add_edges([(15,4),(3,8),(7,12),(11,0),(2,13),(5,10)])
     3435        g.add_edges([(30,6),(29,9),(48,14),(47,1)])
     3436        g.add_edge(32,52)
     3437        g.add_edge(50,52)
     3438        g.add_edge(33,53)
     3439        g.add_edge(51,53)
     3440        g.add_edge(52,53)
     3441
     3442        # Top
     3443        _circle_embedding(g, range(16), center = (0,.5), shift = .5, radius = .5)
     3444
     3445        # Bottom-left
     3446        x = 16
     3447        _circle_embedding(g, range(x,x+6), center = (-1.5,-1))
     3448        x += 6
     3449        _circle_embedding(g, range(x,x+6), center = (-1.5,-1), radius = .5)
     3450        x += 6
     3451        _circle_embedding(g, range(x,x+6), center = (-1.5,-1), radius = .7)
     3452
     3453        # Bottom right
     3454        x += 6
     3455        _circle_embedding(g, range(x,x+6), center = (1.5,-1))
     3456        x += 6
     3457        _circle_embedding(g, range(x,x+6), center = (1.5,-1), radius = .5)
     3458        x += 6
     3459        _circle_embedding(g, range(x,x+6), center = (1.5,-1), radius = .7)
     3460
     3461        d = g.get_pos()
     3462        d[52] = (-.3,-2.5)
     3463        d[53] = (.3,-2.5)
     3464        d[31] = (-2.2,-.9)
     3465        d[28] = (-.8,-.9)
     3466        d[46] = (2.2,-.9)
     3467        d[49] = (.8,-.9)
     3468
     3469        return g
     3470
     3471    def EllinghamHorton78Graph(self):
     3472        r"""
     3473        Returns the Ellingham-Horton 78-graph.
     3474
     3475        For more information, see the :wikipedia:`Wikipedia page on the
     3476        Ellingham-Horton graphs
     3477        <http://en.wikipedia.org/wiki/Ellingham%E2%80%93Horton_graph>`
     3478
     3479        EXAMPLE:
     3480
     3481        This graph is 3-regular::
     3482
     3483            sage: g = graphs.EllinghamHorton78Graph()
     3484            sage: g.is_regular(k=3)
     3485            True
     3486
     3487        It is 3-connected and bipartite::
     3488
     3489            sage: g.vertex_connectivity() # not tested - too long
     3490            3
     3491            sage: g.is_bipartite()
     3492            True
     3493
     3494        It is not Hamiltonian::
     3495
     3496            sage: g.is_hamiltonian() # not tested - too long
     3497            False
     3498
     3499        ... and it has a nice drawing ::
     3500
     3501            sage: g.show(figsize=[10,10]) # not tested - too long
     3502
     3503        TESTS::
     3504
     3505            sage: g.show() # long time
     3506        """
     3507        g = graph.Graph({
     3508                0: [1, 5, 60], 1: [2, 12], 2: [3, 7], 3: [4, 14], 4: [5, 9],
     3509                5: [6], 6: [7, 11], 7: [15], 8: [9, 13, 22], 9: [10], 10: [11, 72],
     3510                11: [12], 12: [13], 13: [14], 14: [72], 15: [16, 20], 16: [17, 27],
     3511                17: [18, 22], 18: [19, 29], 19: [20, 24], 20: [21], 21: [22, 26],
     3512                23: [24, 28, 72], 24: [25], 25: [26, 71], 26: [27], 27: [28],
     3513                28: [29], 29: [69], 30: [31, 35, 52], 31: [32, 42], 32: [33, 37],
     3514                33: [34, 43], 34: [35, 39], 35: [36], 36: [41, 63], 37: [65, 66],
     3515                38: [39, 59, 74], 39: [40], 40: [41, 44], 41: [42], 42: [74],
     3516                43: [44, 74], 44: [45], 45: [46, 50], 46: [47, 57], 47: [48, 52],
     3517                48: [49, 75], 49: [50, 54], 50: [51], 51: [52, 56], 53: [54, 58, 73],
     3518                54: [55], 55: [56, 59], 56: [57], 57: [58], 58: [75], 59: [75],
     3519                60: [61, 64], 61: [62, 71], 62: [63, 77], 63: [67], 64: [65, 69],
     3520                65: [77], 66: [70, 73], 67: [68, 73], 68: [69, 76], 70: [71, 76], 76: [77]}, pos = {})
     3521
     3522        _circle_embedding(g, range(15), center = (-2.5,1.5))
     3523        _circle_embedding(g, range(15, 30), center = (-2.5,-1.5))
     3524        _circle_embedding(g, [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 74, 43, 44], center = (2.5,1.5))
     3525        _circle_embedding(g, [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 75, 59], center = (2.5,-1.5))
     3526
     3527        d = g.get_pos()
     3528
     3529        d[76] = (-.2,-.1)
     3530        d[77] = (.2,.1)
     3531        d[38] = (2.2,.1)
     3532        d[52] = (2.3,-.1)
     3533        d[15] = (-2.1,-.1)
     3534        d[72] = (-2.1,.1)
     3535
     3536        _line_embedding(g, [60,61,62,63], first = (-1,2), last=(1,2))
     3537        _line_embedding(g, [64,65,37], first = (-.5,1.5), last=(1.2,1.5))
     3538        _line_embedding(g, [66,73,67,68, 69], first = (1.2,-2), last=(-.8,-2))
     3539        _line_embedding(g, [66,70,71], first = (.7,-1.5), last=(-1,-1.5))
     3540
     3541        g.name("Ellingham-Horton 78 Graph")
     3542        return g
     3543
    33763544    def ErreraGraph(self):
    33773545        r"""
    33783546        Returns the Errera graph.