Ticket #10310: trac-10310_brinkmann-graph.patch

File trac-10310_brinkmann-graph.patch, 3.8 KB (added by mvngu, 9 years ago)
  • sage/graphs/graph_generators.py

    # HG changeset patch
    # User Minh Van Nguyen <nguyenminh2@gmail.com>
    # Date 1290449420 28800
    # Node ID 016114fa8bdbef95e9845e3d2181dc15711cc4d2
    # Parent  e94d290240e1306a2d1f544f9352c82ba020828d
    #10310: add Brinkmann graph to common graph database
    
    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    9393------------
    9494
    9595- :meth:`BidiakisCube <GraphGenerators.BidiakisCube>`
     96- :meth:`BrinkmannGraph <GraphGenerators.BrinkmannGraph>`
    9697- :meth:`ChvatalGraph <GraphGenerators.ChvatalGraph>`
    9798- :meth:`DesarguesGraph <GraphGenerators.DesarguesGraph>`
    9899- :meth:`FlowerSnark <GraphGenerators.FlowerSnark>`
     
    21412142            11: [-0.5, 0.866025403784439]}
    21422143        return graph.Graph(edge_dict, pos=pos_dict, name="Bidiakis cube")
    21432144
     2145    def BrinkmannGraph(self):
     2146        r"""
     2147        Returns the Brinkmann graph.
     2148
     2149        For more information, see the
     2150        `Wikipedia article on the Brinkmann graph <http://en.wikipedia.org/wiki/Brinkmann_graph>`_.
     2151
     2152        EXAMPLES:
     2153
     2154        The Brinkmann graph is a 4-regular graph having 21 vertices and 42
     2155        edges. This means that each vertex has degree 4. ::
     2156
     2157            sage: G = graphs.BrinkmannGraph(); G
     2158            Brinkmann graph: Graph on 21 vertices
     2159            sage: G.show()  # long time
     2160            sage: G.order()
     2161            21
     2162            sage: G.size()
     2163            42
     2164            sage: def is_4regular(G):
     2165            ...       D = G.degree_sequence()
     2166            ...       return all(d == 4 for d in D)
     2167            sage: is_4regular(G)
     2168            True
     2169
     2170        It is an Eulerian graph with radius 3, diameter 3, and girth 5. ::
     2171
     2172            sage: G.is_eulerian()
     2173            True
     2174            sage: G.radius()
     2175            3
     2176            sage: G.diameter()
     2177            3
     2178            sage: G.girth()
     2179            5
     2180
     2181        The Brinkmann graph is also Hamiltonian with chromatic number 4::
     2182
     2183            sage: G.is_hamiltonian()
     2184            True
     2185            sage: G.chromatic_number()
     2186            4
     2187        """
     2188        edge_dict = {
     2189            0: [2,5,7,13],
     2190            1: [3,6,7,8],
     2191            2: [4,8,9],
     2192            3: [5,9,10],
     2193            4: [6,10,11],
     2194            5: [11,12],
     2195            6: [12,13],
     2196            7: [15,20],
     2197            8: [14,16],
     2198            9: [15,17],
     2199            10: [16,18],
     2200            11: [17,19],
     2201            12: [18,20],
     2202            13: [14,19],
     2203            14: [17,18],
     2204            15: [18,19],
     2205            16: [19,20],
     2206            17: [20]}
     2207        pos_dict = {
     2208            0: [0, 4],
     2209            1: [3.12732592987212, 2.49395920743493],
     2210            2: [3.89971164872729, -0.890083735825258],
     2211            3: [1.73553495647023, -3.60387547160968],
     2212            4: [-1.73553495647023, -3.60387547160968],
     2213            5: [-3.89971164872729, -0.890083735825258],
     2214            6: [-3.12732592987212, 2.49395920743493],
     2215            7: [0.867767478235116, 1.80193773580484],
     2216            8: [1.94985582436365, 0.445041867912629],
     2217            9: [1.56366296493606, -1.24697960371747],
     2218            10: [0, -2],
     2219            11: [-1.56366296493606, -1.24697960371747],
     2220            12: [-1.94985582436365, 0.445041867912629],
     2221            13: [-0.867767478235116, 1.80193773580484],
     2222            14: [0.433883739117558, 0.900968867902419],
     2223            15: [0.974927912181824, 0.222520933956314],
     2224            16: [0.781831482468030, -0.623489801858733],
     2225            17: [0, -1],
     2226            18: [-0.781831482468030, -0.623489801858733],
     2227            19: [-0.974927912181824, 0.222520933956315],
     2228            20: [-0.433883739117558, 0.900968867902419]}
     2229        return graph.Graph(edge_dict, pos=pos_dict, name="Brinkmann graph")
     2230
    21442231    def ChvatalGraph(self):
    21452232        r"""
    21462233        Returns the Chvatal graph.