Ticket #10337: trac-10337_herschel-graph.patch

File trac-10337_herschel-graph.patch, 3.2 KB (added by mvngu, 11 years ago)
  • sage/graphs/graph_generators.py

    # HG changeset patch
    # User Minh Van Nguyen <nguyenminh2@gmail.com>
    # Date 1290767901 -39600
    # Node ID 00e20dafe341dfb7339b5fd91cfe8b84eeb90bfe
    # Parent  f5f46e3c23f937a1c7d4366859e347ee7a009d98
    #10337: add Herschel graph to the common graphs database
    
    diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py
    a b  
    107107- :meth:`GoldnerHararyGraph <GraphGenerators.GoldnerHararyGraph>`
    108108- :meth:`GrotzschGraph <GraphGenerators.GrotzschGraph>`
    109109- :meth:`HeawoodGraph <GraphGenerators.HeawoodGraph>`
     110- :meth:`HerschelGraph <GraphGenerators.HerschelGraph>`
    110111- :meth:`HigmanSimsGraph <GraphGenerators.HigmanSimsGraph>`
    111112- :meth:`HoffmanSingletonGraph <GraphGenerators.HoffmanSingletonGraph>`
    112113- :meth:`MoebiusKantorGraph <GraphGenerators.MoebiusKantorGraph>`
     
    27842785        g.set_pos(pos)
    27852786        g.name("Grotzsch graph")
    27862787        return g
    2787 
    27882788   
    27892789    def HeawoodGraph(self):
    27902790        """
     
    28262826        G = networkx.heawood_graph()
    28272827        return graph.Graph(G, pos=pos_dict, name="Heawood graph")
    28282828
     2829    def HerschelGraph(self):
     2830        r"""
     2831        Returns the Herschel graph.
     2832
     2833        For more information, see this
     2834        `Wikipedia article on the Herschel graph <http://en.wikipedia.org/wiki/Herschel_graph>`_.
     2835
     2836        EXAMPLES:
     2837
     2838        The Herschel graph is named after Alexander Stewart Herschel. It is
     2839        a planar, bipartite graph with 11 vertices and 18 edges. ::
     2840
     2841            sage: G = graphs.HerschelGraph(); G
     2842            Herschel graph: Graph on 11 vertices
     2843            sage: G.is_planar()
     2844            True
     2845            sage: G.is_bipartite()
     2846            True
     2847            sage: G.order()
     2848            11
     2849            sage: G.size()
     2850            18
     2851
     2852        The Herschel graph is a perfect graph with radius 3, diameter 4, and
     2853        girth 4. ::
     2854
     2855            sage: G.is_perfect()
     2856            True
     2857            sage: G.radius()
     2858            3
     2859            sage: G.diameter()
     2860            4
     2861            sage: G.girth()
     2862            4
     2863
     2864        Its chromatic number is 2 and its automorphism group is
     2865        isomorphic to the dihedral group `D_6`. ::
     2866
     2867            sage: G.chromatic_number()
     2868            2
     2869            sage: ag = G.automorphism_group()
     2870            sage: ag.is_isomorphic(DihedralGroup(6))
     2871            True
     2872        """
     2873        edge_dict = {
     2874            0: [1,3,4],
     2875            1: [2,5,6],
     2876            2: [3,7],
     2877            3: [8,9],
     2878            4: [5,9],
     2879            5: [10],
     2880            6: [7,10],
     2881            7: [8],
     2882            8: [10],
     2883            9: [10]}
     2884        pos_dict = {
     2885            0: [2, 0],
     2886            1: [0, 2],
     2887            2: [-2, 0],
     2888            3: [0, -2],
     2889            4: [1, 0],
     2890            5: [0.5, 0.866025403784439],
     2891            6: [-0.5, 0.866025403784439],
     2892            7: [-1, 0],
     2893            8: [-0.5, -0.866025403784439],
     2894            9: [0.5, -0.866025403784439],
     2895            10: [0, 0]}
     2896        return graph.Graph(edge_dict, pos=pos_dict, name="Herschel graph")
     2897
    28292898    def HigmanSimsGraph(self, relabel=True):
    28302899        r"""
    28312900        The Higman-Sims graph is a remarkable strongly regular