Ticket #10790: trac_10790-Dyck-graph.patch

File trac_10790-Dyck-graph.patch, 5.1 KB (added by kini, 11 years ago)
  • sage/graphs/graph_generators.py

    # HG changeset patch
    # User Keshav Kini <kini@member.ams.org>
    # Date 1300392989 25200
    # Node ID 0718067e663e539db7611058fbabb3f4ede1061d
    # Parent 22eb5dbbd70ec3330f936e7b7e12b9c1ea22e206
    trac #10790: add Dyck graph to the common graphs database
    
    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    100100- :meth:`ChvatalGraph <GraphGenerators.ChvatalGraph>`
    101101- :meth:`DesarguesGraph <GraphGenerators.DesarguesGraph>`
    102102- :meth:`DurerGraph <GraphGenerators.DurerGraph>`
     103- :meth:`DyckGraph <GraphGenerators.DyckGraph>`
    103104- :meth:`ErreraGraph <GraphGenerators.ErreraGraph>`
    104105- :meth:`FlowerSnark <GraphGenerators.FlowerSnark>`
    105106- :meth:`FranklinGraph <GraphGenerators.FranklinGraph>`
     
    222223
    223224- Minh Van Nguyen (2010-11-26): added more named graphs
    224225
    225 - Keshav Kini (2011-02-16): added Shrikhande graph
     226- Keshav Kini (2011-02-16): added Shrikhande and Dyck graphs
    226227
    227228"""
    228229
     
    24302431            11: [0.5, -0.866025403784439]}
    24312432        return graph.Graph(edge_dict, pos=pos_dict, name="Durer graph")
    24322433
     2434    def DyckGraph(self):
     2435        """
     2436        Returns the Dyck graph.
     2437
     2438        For more information, see the `MathWorld article on the Dyck graph
     2439        <http://mathworld.wolfram.com/DyckGraph.html>`_ or the `Wikipedia
     2440        article on the Dyck graph <http://en.wikipedia.org/wiki/Dyck_graph>`_.
     2441
     2442        EXAMPLES:
     2443
     2444        The Dyck graph was defined by Walther von Dyck in 1881. It has `32`
     2445        vertices and `48` edges, and is a cubic graph (regular of degree `3`)::
     2446           
     2447            sage: G = graphs.DyckGraph(); G
     2448            Dyck graph: Graph on 32 vertices
     2449            sage: G.order()
     2450            32
     2451            sage: G.size()
     2452            48
     2453            sage: G.is_regular()
     2454            True
     2455            sage: G.is_regular(3)
     2456            True
     2457
     2458        It is non-planar and Hamiltonian, as well as bipartite (making it a
     2459        bicubic graph)::
     2460           
     2461            sage: G.is_planar()
     2462            False
     2463            sage: G.is_hamiltonian()
     2464            True
     2465            sage: G.is_bipartite()
     2466            True
     2467
     2468        It has radius `5`, diameter `5`, and girth `6`::
     2469           
     2470            sage: G.radius()
     2471            5
     2472            sage: G.diameter()
     2473            5
     2474            sage: G.girth()
     2475            6
     2476
     2477        Its chromatic number is `2` and its automorphism group is of order
     2478        `192`::
     2479           
     2480            sage: G.chromatic_number()
     2481            2
     2482            sage: G.automorphism_group().cardinality()
     2483            192
     2484
     2485        It is a non-integral graph as it has irrational eigenvalues::
     2486           
     2487            sage: G.characteristic_polynomial().factor()
     2488            (x - 3) * (x + 3) * (x - 1)^9 * (x + 1)^9 * (x^2 - 5)^6
     2489
     2490        It is a toroidal graph, and its embedding on a torus is dual to an
     2491        embedding of the Shrikhande graph (:meth:`ShrikhandeGraph
     2492        <GraphGenerators.ShrikhandeGraph>`).
     2493        """
     2494        pos_dict = {}
     2495        for i in range(8):
     2496            pos_dict[i] = [float(cos((2*i) * pi/8)),
     2497                           float(sin((2*i) * pi/8))]
     2498            pos_dict[8 + i]  = [0.75 * pos_dict[i][0],
     2499                                0.75 * pos_dict[i][1]]
     2500            pos_dict[16 + i] = [0.50 * pos_dict[i][0],
     2501                                0.50 * pos_dict[i][1]]
     2502            pos_dict[24 + i] = [0.25 * pos_dict[i][0],
     2503                                0.25 * pos_dict[i][1]]
     2504
     2505        edge_dict = {
     2506            0O00: [0O07, 0O01,   0O10], 0O10: [0O00,   0O27, 0O21],
     2507            0O01: [0O00, 0O02,   0O11], 0O11: [0O01,   0O20, 0O22],
     2508            0O02: [0O01, 0O03,   0O12], 0O12: [0O02,   0O21, 0O23],
     2509            0O03: [0O02, 0O04,   0O13], 0O13: [0O03,   0O22, 0O24],
     2510            0O04: [0O03, 0O05,   0O14], 0O14: [0O04,   0O23, 0O25],
     2511            0O05: [0O04, 0O06,   0O15], 0O15: [0O05,   0O24, 0O26],
     2512            0O06: [0O05, 0O07,   0O16], 0O16: [0O06,   0O25, 0O27],
     2513            0O07: [0O06, 0O00,   0O17], 0O17: [0O07,   0O26, 0O20],
     2514
     2515            0O20: [0O17, 0O11,   0O30], 0O30: [0O20,   0O35, 0O33],
     2516            0O21: [0O10, 0O12,   0O31], 0O31: [0O21,   0O36, 0O34],
     2517            0O22: [0O11, 0O13,   0O32], 0O32: [0O22,   0O37, 0O35],
     2518            0O23: [0O12, 0O14,   0O33], 0O33: [0O23,   0O30, 0O36],
     2519            0O24: [0O13, 0O15,   0O34], 0O34: [0O24,   0O31, 0O37],
     2520            0O25: [0O14, 0O16,   0O35], 0O35: [0O25,   0O32, 0O30],
     2521            0O26: [0O15, 0O17,   0O36], 0O36: [0O26,   0O33, 0O31],
     2522            0O27: [0O16, 0O10,   0O37], 0O37: [0O27,   0O34, 0O32],
     2523        }
     2524
     2525        return graph.Graph(edge_dict, pos=pos_dict, name="Dyck graph")
     2526
    24332527    def ErreraGraph(self):
    24342528        r"""
    24352529        Returns the Errera graph.
     
    35403634           
    35413635            sage: G.characteristic_polynomial().factor()
    35423636            (x - 6) * (x - 2)^6 * (x + 2)^9
     3637
     3638        It is a toroidal graph, and its embedding on a torus is dual to an
     3639        embedding of the Dyck graph (:meth:`DyckGraph <GraphGenerators.DyckGraph>`).
    35433640        """
    35443641        pos_dict = {}
    35453642        for i in range(8):