Ticket #12971: trac_12971.patch

File trac_12971.patch, 4.0 KB (added by ncohen, 9 years ago)
  • sage/graphs/graph_generators.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1337347480 -7200
    # Node ID 1e6090113307bda4df1d122f817121358308d186
    # Parent  c100a3aeb12fb7dee4375ec077c581180696cbf3
    Adds the Biggs-Smith graph to our graph constructors
    
    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    9898- :meth:`Balaban10Cage <GraphGenerators.Balaban10Cage>`
    9999- :meth:`Balaban11Cage <GraphGenerators.Balaban11Cage>`
    100100- :meth:`BidiakisCube <GraphGenerators.BidiakisCube>`
     101- :meth:`BiggsSmith <GraphGenerators.BiggsSmith>`
    101102- :meth:`BrinkmannGraph <GraphGenerators.BrinkmannGraph>`
    102103- :meth:`DoubleStarSnark <GraphGenerators.DoubleStarSnark>`
    103104- :meth:`ChvatalGraph <GraphGenerators.ChvatalGraph>`
     
    28012802            11: [-0.5, 0.866025403784439]}
    28022803        return graph.Graph(edge_dict, pos=pos_dict, name="Bidiakis cube")
    28032804
     2805    def BiggsSmith(self, embedding = 1):
     2806        r"""
     2807        Returns the Biggs-Smith graph.
     2808
     2809        For more information, see this :wikipedia:`Wikipedia article on
     2810        the Biggs-Smith graph <Biggs-Smith_graph>`.
     2811
     2812        INPUT:
     2813
     2814        - ``embedding`` -- two embeddings are available, and can be
     2815          selected by setting ``embedding`` to be 1 or 2.
     2816
     2817        EXAMPLES:
     2818
     2819        Basic properties::
     2820
     2821            sage: g = graphs.BiggsSmith()
     2822            sage: g.order()
     2823            102
     2824            sage: g.size()
     2825            153
     2826            sage: g.girth()
     2827            9
     2828            sage: g.diameter()
     2829            7
     2830            sage: g.automorphism_group().cardinality()
     2831            2448
     2832            sage: g.show(figsize=[10,10])
     2833
     2834        The other embedding::
     2835
     2836            sage: graphs.BiggsSmith(embedding = 2).show()
     2837
     2838        TESTS::
     2839
     2840            sage: graphs.BiggsSmith(embedding='xyzzy')
     2841            Traceback (most recent call last):
     2842            ...
     2843            ValueError: The value of embedding must be 1, or 2.
     2844
     2845        """
     2846        L = [16, 24, -38, 17, 34, 48, -19, 41, -35, 47, -20, 34, -36,
     2847             21, 14, 48, -16, -36, -43, 28, -17, 21, 29, -43, 46, -24,
     2848             28, -38, -14, -50, -45, 21, 8, 27, -21, 20, -37, 39, -34,
     2849             -44, -8, 38, -21, 25, 15, -34, 18, -28, -41, 36, 8, -29,
     2850             -21, -48, -28, -20, -47, 14, -8, -15, -27, 38, 24, -48, -18,
     2851             25, 38, 31, -25, 24, -46, -14, 28, 11, 21, 35, -39, 43, 36,
     2852             -38, 14, 50, 43, 36, -11, -36, -24, 45, 8, 19, -25, 38, 20,
     2853             -24, -14, -21, -8, 44, -31, -38, -28, 37]
     2854
     2855        g = graphs.LCFGraph(102, L, 1)
     2856        g.name("Biggs-Smith graph")
     2857
     2858        if embedding == 1:
     2859
     2860            orbs = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0],
     2861                    [17, 101, 25, 66, 20, 38, 53, 89, 48, 75, 56, 92, 45, 78, 34, 28, 63],
     2862                    [18, 36, 26, 65, 19, 37, 54, 90, 47, 76, 55, 91, 46, 77, 35, 27, 64],
     2863                    [21, 39, 52, 88, 49, 74, 57, 93, 44, 79, 33, 29, 62, 83, 100, 24, 67],
     2864                    [22, 97, 51, 96, 50, 95, 58, 94, 59, 80, 60, 81, 61, 82, 99, 23, 98],
     2865                    [30, 86, 84, 72, 70, 68, 42, 40, 31, 87, 85, 73, 71, 69, 43, 41, 32]]
     2866
     2867            # central orbits
     2868            _circle_embedding(g, orbs[1], center = (-.4,0), radius = .2)
     2869            _circle_embedding(g, orbs[3], center = (.4,0), radius = .2, shift = 4)
     2870
     2871            # Lower orbtis
     2872            _circle_embedding(g, orbs[0], center = (-.9,-.5), radius = .3, shift = 2)
     2873            _circle_embedding(g, orbs[2], center = (-.9,.5), radius = .3)
     2874
     2875            # Upper orbits
     2876            _circle_embedding(g, orbs[4], center = (.9,-.5), radius = .3, shift = 4)
     2877            _circle_embedding(g, orbs[5], center = (.9,.5), radius = .3, shift = -2)
     2878
     2879        elif embedding == 2:
     2880            pass
     2881        else:
     2882            raise ValueError("The value of embedding must be 1, or 2.")
     2883
     2884        return g
     2885
    28042886    def BrinkmannGraph(self):
    28052887        r"""
    28062888        Returns the Brinkmann graph.