Ticket #12989: trac_12989.reviewer.patch

File trac_12989.reviewer.patch, 7.9 KB (added by ncohen, 7 years ago)

apply to $SAGE_ROOT/devel/sage

  • sage/graphs/graph_generators.py

    # HG changeset patch
    # User Keshav Kini <keshav.kini@gmail.com>
    # Date 1337830734 25200
    # Node ID 9f740c3ee641e22730b6170c374260cbccdfe773
    # Parent  58b2e6b5fdb249535c3f3efbf44fe1c8ba5bb880
    Formatting, naming, eliminate intermediate vars
    
    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    33953395        Returns the Ellingham-Horton 54-graph.
    33963396
    33973397        For more information, see the :wikipedia:`Wikipedia page on the
    3398         Ellingham-Horton graphs
    3399         <http://en.wikipedia.org/wiki/Ellingham%E2%80%93Horton_graph>`
     3398        Ellingham-Horton graphs <Ellingham-Horton_graph>`
    34003399
    34013400        EXAMPLE:
    34023401
     
    34203419
    34213420        ... and it has a nice drawing ::
    34223421
    3423             sage: g.show(figsize=[10,10]) # not tested - too long
     3422            sage: g.show(figsize=[10, 10]) # not tested - too long
    34243423
    34253424        TESTS::
    34263425
     
    34303429        low = 2*graphs.CycleGraph(6)
    34313430
    34323431        for v in range(6):
    3433             low.add_edge(v, v+12)
    3434             low.add_edge(v+6, v+12)
    3435         low.add_edge(12,15)
    3436         low.delete_edge(1,2)
    3437         low.delete_edge(8,7)
    3438         low.add_edge(1,8)
    3439         low.add_edge(7,2)
     3432            low.add_edge(v, v + 12)
     3433            low.add_edge(v + 6, v + 12)
     3434        low.add_edge(12, 15)
     3435        low.delete_edge(1, 2)
     3436        low.delete_edge(8, 7)
     3437        low.add_edge(1, 8)
     3438        low.add_edge(7, 2)
     3439
    34403440
    34413441        # The set of vertices on top is 0..15
    34423442        # Bottom left is 16..33
    34433443        # Bottom right is 34..52
    34443444        # The two other vertices are 53, 54
    34453445        g = up + 2*low
    3446         g.name("Ellingham-Horton 54 graph.")
     3446        g.name("Ellingham-Horton 54-graph")
    34473447        g.set_pos({})
    34483448
    3449         g.add_edges([(15,4),(3,8),(7,12),(11,0),(2,13),(5,10)])
    3450         g.add_edges([(30,6),(29,9),(48,14),(47,1)])
    3451         g.add_edge(32,52)
    3452         g.add_edge(50,52)
    3453         g.add_edge(33,53)
    3454         g.add_edge(51,53)
    3455         g.add_edge(52,53)
     3449        g.add_edges([(15, 4), (3, 8), (7, 12), (11, 0), (2, 13), (5, 10)])
     3450        g.add_edges([(30, 6), (29, 9), (48, 14), (47, 1)])
     3451        g.add_edge(32, 52)
     3452        g.add_edge(50, 52)
     3453        g.add_edge(33, 53)
     3454        g.add_edge(51, 53)
     3455        g.add_edge(52, 53)
    34563456
    34573457        # Top
    3458         _circle_embedding(g, range(16), center = (0,.5), shift = .5, radius = .5)
     3458        _circle_embedding(g, range(16), center=(0, .5), shift=.5, radius=.5)
    34593459
    34603460        # Bottom-left
    3461         x = 16
    3462         _circle_embedding(g, range(x,x+6), center = (-1.5,-1))
    3463         x += 6
    3464         _circle_embedding(g, range(x,x+6), center = (-1.5,-1), radius = .5)
    3465         x += 6
    3466         _circle_embedding(g, range(x,x+6), center = (-1.5,-1), radius = .7)
     3461        _circle_embedding(g, range(16, 22), center=(-1.5, -1))
     3462        _circle_embedding(g, range(22, 28), center=(-1.5, -1), radius=.5)
     3463        _circle_embedding(g, range(28, 34), center=(-1.5, -1), radius=.7)
    34673464
    34683465        # Bottom right
    3469         x += 6
    3470         _circle_embedding(g, range(x,x+6), center = (1.5,-1))
    3471         x += 6
    3472         _circle_embedding(g, range(x,x+6), center = (1.5,-1), radius = .5)
    3473         x += 6
    3474         _circle_embedding(g, range(x,x+6), center = (1.5,-1), radius = .7)
     3466        _circle_embedding(g, range(34, 40), center=(1.5, -1))
     3467        _circle_embedding(g, range(40, 46), center=(1.5, -1), radius=.5)
     3468        _circle_embedding(g, range(46, 52), center=(1.5, -1), radius=.7)
    34753469
    34763470        d = g.get_pos()
    3477         d[52] = (-.3,-2.5)
    3478         d[53] = (.3,-2.5)
    3479         d[31] = (-2.2,-.9)
    3480         d[28] = (-.8,-.9)
    3481         d[46] = (2.2,-.9)
    3482         d[49] = (.8,-.9)
     3471        d[52] = (-.3, -2.5)
     3472        d[53] = (.3, -2.5)
     3473        d[31] = (-2.2, -.9)
     3474        d[28] = (-.8, -.9)
     3475        d[46] = (2.2, -.9)
     3476        d[49] = (.8, -.9)
     3477
    34833478
    34843479        return g
    34853480
     
    35173512
    35183513        TESTS::
    35193514
    3520             sage: g.show() # long time
     3515            sage: g.show(figsize=[10, 10]) # not tested - too long
    35213516        """
    35223517        g = graph.Graph({
    35233518                0: [1, 5, 60], 1: [2, 12], 2: [3, 7], 3: [4, 14], 4: [5, 9],
    3524                 5: [6], 6: [7, 11], 7: [15], 8: [9, 13, 22], 9: [10], 10: [11, 72],
    3525                 11: [12], 12: [13], 13: [14], 14: [72], 15: [16, 20], 16: [17, 27],
    3526                 17: [18, 22], 18: [19, 29], 19: [20, 24], 20: [21], 21: [22, 26],
    3527                 23: [24, 28, 72], 24: [25], 25: [26, 71], 26: [27], 27: [28],
    3528                 28: [29], 29: [69], 30: [31, 35, 52], 31: [32, 42], 32: [33, 37],
    3529                 33: [34, 43], 34: [35, 39], 35: [36], 36: [41, 63], 37: [65, 66],
    3530                 38: [39, 59, 74], 39: [40], 40: [41, 44], 41: [42], 42: [74],
    3531                 43: [44, 74], 44: [45], 45: [46, 50], 46: [47, 57], 47: [48, 52],
    3532                 48: [49, 75], 49: [50, 54], 50: [51], 51: [52, 56], 53: [54, 58, 73],
    3533                 54: [55], 55: [56, 59], 56: [57], 57: [58], 58: [75], 59: [75],
    3534                 60: [61, 64], 61: [62, 71], 62: [63, 77], 63: [67], 64: [65, 69],
    3535                 65: [77], 66: [70, 73], 67: [68, 73], 68: [69, 76], 70: [71, 76], 76: [77]}, pos = {})
    3536 
    3537         _circle_embedding(g, range(15), center = (-2.5,1.5))
    3538         _circle_embedding(g, range(15, 30), center = (-2.5,-1.5))
    3539         _circle_embedding(g, [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 74, 43, 44], center = (2.5,1.5))
    3540         _circle_embedding(g, [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 75, 59], center = (2.5,-1.5))
     3519                5: [6], 6: [7, 11], 7: [15], 8: [9, 13, 22], 9: [10],
     3520                10: [11, 72], 11: [12], 12: [13], 13: [14], 14: [72],
     3521                15: [16, 20], 16: [17, 27], 17: [18, 22], 18: [19, 29],
     3522                19: [20, 24], 20: [21], 21: [22, 26], 23: [24, 28, 72],
     3523                24: [25], 25: [26, 71], 26: [27], 27: [28], 28: [29],
     3524                29: [69], 30: [31, 35, 52], 31: [32, 42], 32: [33, 37],
     3525                33: [34, 43], 34: [35, 39], 35: [36], 36: [41, 63],
     3526                37: [65, 66], 38: [39, 59, 74], 39: [40], 40: [41, 44],
     3527                41: [42], 42: [74], 43: [44, 74], 44: [45], 45: [46, 50],
     3528                46: [47, 57], 47: [48, 52], 48: [49, 75], 49: [50, 54],
     3529                50: [51], 51: [52, 56], 53: [54, 58, 73], 54: [55],
     3530                55: [56, 59], 56: [57], 57: [58], 58: [75], 59: [75],
     3531                60: [61, 64], 61: [62, 71], 62: [63, 77], 63: [67],
     3532                64: [65, 69], 65: [77], 66: [70, 73], 67: [68, 73],
     3533                68: [69, 76], 70: [71, 76], 76: [77]}, pos={})
     3534
     3535        _circle_embedding(g, range(15), center=(-2.5, 1.5))
     3536        _circle_embedding(g, range(15, 30), center=(-2.5, -1.5))
     3537        _circle_embedding(g, [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
     3538            42, 74, 43, 44], center=(2.5, 1.5))
     3539        _circle_embedding(g, [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
     3540            57, 58, 75, 59], center=(2.5, -1.5))
    35413541
    35423542        d = g.get_pos()
    35433543
    3544         d[76] = (-.2,-.1)
    3545         d[77] = (.2,.1)
    3546         d[38] = (2.2,.1)
    3547         d[52] = (2.3,-.1)
    3548         d[15] = (-2.1,-.1)
    3549         d[72] = (-2.1,.1)
    3550 
    3551         _line_embedding(g, [60,61,62,63], first = (-1,2), last=(1,2))
    3552         _line_embedding(g, [64,65,37], first = (-.5,1.5), last=(1.2,1.5))
    3553         _line_embedding(g, [66,73,67,68, 69], first = (1.2,-2), last=(-.8,-2))
    3554         _line_embedding(g, [66,70,71], first = (.7,-1.5), last=(-1,-1.5))
    3555 
    3556         g.name("Ellingham-Horton 78 Graph")
     3544        d[76] = (-.2, -.1)
     3545        d[77] = (.2, .1)
     3546        d[38] = (2.2, .1)
     3547        d[52] = (2.3, -.1)
     3548        d[15] = (-2.1, -.1)
     3549        d[72] = (-2.1, .1)
     3550
     3551        _line_embedding(g, [60, 61, 62, 63], first=(-1, 2), last=(1, 2))
     3552        _line_embedding(g, [64, 65, 37], first=(-.5, 1.5), last=(1.2, 1.5))
     3553        _line_embedding(g, [66, 73, 67, 68, 69], first=(1.2, -2),
     3554                last=(-.8, -2))
     3555        _line_embedding(g, [66, 70, 71], first=(.7, -1.5), last=(-1, -1.5))
     3556
     3557        g.name("Ellingham-Horton 78-graph")
     3558
    35573559        return g
    35583560
    35593561    def ErreraGraph(self):