# 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 - :meth:`ChvatalGraph ` - :meth:`DesarguesGraph ` - :meth:`DurerGraph ` - :meth:`DyckGraph ` - :meth:`ErreraGraph ` - :meth:`FlowerSnark ` - :meth:`FranklinGraph ` - Minh Van Nguyen (2010-11-26): added more named graphs - Keshav Kini (2011-02-16): added Shrikhande graph - Keshav Kini (2011-02-16): added Shrikhande and Dyck graphs """ 11: [0.5, -0.866025403784439]} return graph.Graph(edge_dict, pos=pos_dict, name="Durer graph") def DyckGraph(self): """ Returns the Dyck graph. For more information, see the `MathWorld article on the Dyck graph `_ or the `Wikipedia article on the Dyck graph `_. EXAMPLES: The Dyck graph was defined by Walther von Dyck in 1881. It has `32` vertices and `48` edges, and is a cubic graph (regular of degree `3`):: sage: G = graphs.DyckGraph(); G Dyck graph: Graph on 32 vertices sage: G.order() 32 sage: G.size() 48 sage: G.is_regular() True sage: G.is_regular(3) True It is non-planar and Hamiltonian, as well as bipartite (making it a bicubic graph):: sage: G.is_planar() False sage: G.is_hamiltonian() True sage: G.is_bipartite() True It has radius `5`, diameter `5`, and girth `6`:: sage: G.radius() 5 sage: G.diameter() 5 sage: G.girth() 6 Its chromatic number is `2` and its automorphism group is of order `192`:: sage: G.chromatic_number() 2 sage: G.automorphism_group().cardinality() 192 It is a non-integral graph as it has irrational eigenvalues:: sage: G.characteristic_polynomial().factor() (x - 3) * (x + 3) * (x - 1)^9 * (x + 1)^9 * (x^2 - 5)^6 It is a toroidal graph, and its embedding on a torus is dual to an embedding of the Shrikhande graph (:meth:`ShrikhandeGraph `). """ pos_dict = {} for i in range(8): pos_dict[i] = [float(cos((2*i) * pi/8)), float(sin((2*i) * pi/8))] pos_dict[8 + i]  = [0.75 * pos_dict[i][0], 0.75 * pos_dict[i][1]] pos_dict[16 + i] = [0.50 * pos_dict[i][0], 0.50 * pos_dict[i][1]] pos_dict[24 + i] = [0.25 * pos_dict[i][0], 0.25 * pos_dict[i][1]] edge_dict = { 0O00: [0O07, 0O01,   0O10], 0O10: [0O00,   0O27, 0O21], 0O01: [0O00, 0O02,   0O11], 0O11: [0O01,   0O20, 0O22], 0O02: [0O01, 0O03,   0O12], 0O12: [0O02,   0O21, 0O23], 0O03: [0O02, 0O04,   0O13], 0O13: [0O03,   0O22, 0O24], 0O04: [0O03, 0O05,   0O14], 0O14: [0O04,   0O23, 0O25], 0O05: [0O04, 0O06,   0O15], 0O15: [0O05,   0O24, 0O26], 0O06: [0O05, 0O07,   0O16], 0O16: [0O06,   0O25, 0O27], 0O07: [0O06, 0O00,   0O17], 0O17: [0O07,   0O26, 0O20], 0O20: [0O17, 0O11,   0O30], 0O30: [0O20,   0O35, 0O33], 0O21: [0O10, 0O12,   0O31], 0O31: [0O21,   0O36, 0O34], 0O22: [0O11, 0O13,   0O32], 0O32: [0O22,   0O37, 0O35], 0O23: [0O12, 0O14,   0O33], 0O33: [0O23,   0O30, 0O36], 0O24: [0O13, 0O15,   0O34], 0O34: [0O24,   0O31, 0O37], 0O25: [0O14, 0O16,   0O35], 0O35: [0O25,   0O32, 0O30], 0O26: [0O15, 0O17,   0O36], 0O36: [0O26,   0O33, 0O31], 0O27: [0O16, 0O10,   0O37], 0O37: [0O27,   0O34, 0O32], } return graph.Graph(edge_dict, pos=pos_dict, name="Dyck graph") def ErreraGraph(self): r""" Returns the Errera graph. sage: G.characteristic_polynomial().factor() (x - 6) * (x - 2)^6 * (x + 2)^9 It is a toroidal graph, and its embedding on a torus is dual to an embedding of the Dyck graph (:meth:`DyckGraph `). """ pos_dict = {} for i in range(8):