Path: blob/master/src/sage/graphs/generators/smallgraphs.py
8815 views
# -*- coding: utf-8 -*-1r"""2Small graphs34The methods defined here appear in :mod:`sage.graphs.graph_generators`.5"""6#*****************************************************************************7# Copyright (C) 2006 Robert L. Miller <[email protected]>8# and Emily A. Kirkman9# Copyright (C) 2009 Michael C. Yurko <[email protected]>10#11# Distributed under the terms of the GNU General Public License (GPL)12# as published by the Free Software Foundation; either version 2 of13# the License, or (at your option) any later version.14# http://www.gnu.org/licenses/15#*****************************************************************************161718# import from Sage library19from sage.graphs.graph import Graph20from math import sin, cos, pi21from sage.graphs.graph_plot import _circle_embedding, _line_embedding2223#######################################################################24# Named Graphs25#######################################################################2627def HarriesGraph(embedding=1):28r"""29Returns the Harries Graph.3031The Harries graph is a Hamiltonian 3-regular graph on 7032vertices. See the :wikipedia:`Wikipedia page on the Harries33graph <Harries_graph>`.3435The default embedding here is to emphasize the graph's 4 orbits.36This graph actually has a funny construction. The following37procedure gives an idea of it, though not all the adjacencies38are being properly defined.3940#. Take two disjoint copies of a :meth:`Petersen graph41<PetersenGraph>`. Their vertices will form an orbit of the42final graph.4344#. Subdivide all the edges once, to create 15+15=30 new45vertices, which together form another orbit.4647#. Create 15 vertices, each of them linked to 2 corresponding48vertices of the previous orbit, one in each of the two49subdivided Petersen graphs. At the end of this step all50vertices from the previous orbit have degree 3, and the only51vertices of degree 2 in the graph are those that were just52created.5354#. Create 5 vertices connected only to the ones from the55previous orbit so that the graph becomes 3-regular.5657INPUT:5859- ``embedding`` -- two embeddings are available, and can be60selected by setting ``embedding`` to 1 or 2.6162EXAMPLES::6364sage: g = graphs.HarriesGraph()65sage: g.order()667067sage: g.size()6810569sage: g.girth()701071sage: g.diameter()72673sage: g.show(figsize=[10, 10]) # long time74sage: graphs.HarriesGraph(embedding=2).show(figsize=[10, 10]) # long time7576TESTS::7778sage: graphs.HarriesGraph(embedding=3)79Traceback (most recent call last):80...81ValueError: The value of embedding must be 1 or 2.8283"""84from sage.graphs.generators.families import LCFGraph85g = LCFGraph(70, [-29, -19, -13, 13, 21, -27, 27, 33, -13, 13,8619, -21, -33, 29], 5)87g.name("Harries Graph")8889if embedding == 1:90gpos = g.get_pos()91ppos = PetersenGraph().get_pos()9293# The graph's four orbits94o = [None]*495o[0] = [0, 2, 6, 8, 14, 16, 20, 22, 28, 30, 34, 36, 42, 44, 48, 50,9656, 58, 62, 64]97o[1] = [1, 3, 5, 7, 9, 13, 15, 17, 19, 21, 23, 27, 29, 31, 33, 35,9837, 41, 43, 45, 47, 49, 51, 55, 57, 59, 61, 63, 65, 69]99o[2] = [60, 10, 12, 4, 24, 26, 18, 38, 40, 32, 52, 54, 46, 66, 68]100o[3] = [11, 25, 39, 53, 67]101102# Correspondence between the vertices of one of the two Petersen103# graphs on o[0] and the vertices of a standard Petersen graph104# object105g_to_p = {0: 0, 2: 1, 42: 5, 44: 8, 14: 7, 16: 2, 56: 9, 58: 6,10628: 4, 30: 3}107108# Correspondence between the vertices of the other Petersen graph109# on o[0] and the vertices of the first one110g_to_g = {64: 44, 34: 0, 36: 28, 6: 2, 8: 58, 48: 16, 50: 30,11120: 14, 22: 56, 62: 42}112113# Position for the vertices from the first copy114for v, i in g_to_p.iteritems():115gpos[v] = ppos[i]116117# Position for the vertices in the second copy. Moves the first,118# too.119offset = 3.5120for v, i in g_to_g.iteritems():121x, y = gpos[i]122gpos[v] = (x + offset*0.5, y)123gpos[i] = (x - offset*0.5, y)124125# Vertices from o[1]. These are actually the "edges" of the126# copies of Petersen.127for v in o[1]:128p1, p2 = [gpos[x] for x in g.neighbors(v) if x in o[0]]129gpos[v] = ((p1[0] + p2[0])/2, (p1[1] + p2[1])/2)130131# 15 vertices from o[2]132for i, v in enumerate(o[2]):133gpos[v] = (-1.75 + i*.25, 2)134135# 5 vertices from o[3]136for i, v in enumerate(o[3]):137gpos[v] = (-1 + i*.5, 2.5)138139return g140141elif embedding == 2:142return g143else:144raise ValueError("The value of embedding must be 1 or 2.")145146def HarriesWongGraph(embedding=1):147r"""148Returns the Harries-Wong Graph.149150See the :wikipedia:`Wikipedia page on the Harries-Wong graph151<Harries-Wong_graph>`.152153*About the default embedding:*154155The default embedding is an attempt to emphasize the graph's1568 (!!!) different orbits. In order to understand this better,157one can picture the graph as being built in the following way:158159#. One first creates a 3-dimensional cube (8 vertices, 12160edges), whose vertices define the first orbit of the161final graph.162163#. The edges of this graph are subdivided once, to create 12164new vertices which define a second orbit.165166#. The edges of the graph are subdivided once more, to167create 24 new vertices giving a third orbit.168169#. 4 vertices are created and made adjacent to the vertices170of the second orbit so that they have degree1713. These 4 vertices also define a new orbit.172173#. In order to make the vertices from the third orbit1743-regular (they all miss one edge), one creates a binary175tree on 1 + 3 + 6 + 12 vertices. The leaves of this new176tree are made adjacent to the 12 vertices of the third177orbit, and the graph is now 3-regular. This binary tree178contributes 4 new orbits to the Harries-Wong graph.179180INPUT:181182- ``embedding`` -- two embeddings are available, and can be183selected by setting ``embedding`` to 1 or 2.184185EXAMPLES::186187sage: g = graphs.HarriesWongGraph()188sage: g.order()18970190sage: g.size()191105192sage: g.girth()19310194sage: g.diameter()1956196sage: orbits = g.automorphism_group(orbits=True)[-1]197sage: g.show(figsize=[15, 15], partition=orbits) # long time198199Alternative embedding::200201sage: graphs.HarriesWongGraph(embedding=2).show()202203TESTS::204205sage: graphs.HarriesWongGraph(embedding=3)206Traceback (most recent call last):207...208ValueError: The value of embedding must be 1 or 2.209"""210211L = [9, 25, 31, -17, 17, 33, 9, -29, -15, -9, 9, 25, -25, 29, 17, -9,2129, -27, 35, -9, 9, -17, 21, 27, -29, -9, -25, 13, 19, -9, -33,213-17, 19, -31, 27, 11, -25, 29, -33, 13, -13, 21, -29, -21, 25,2149, -11, -19, 29, 9, -27, -19, -13, -35, -9, 9, 17, 25, -9, 9, 27,215-27, -21, 15, -9, 29, -29, 33, -9, -25]216217from sage.graphs.generators.families import LCFGraph218g = LCFGraph(70, L, 1)219g.name("Harries-Wong graph")220221if embedding == 1:222d = g.get_pos()223224# Binary tree (left side)225d[66] = (-9.5, 0)226_line_embedding(g, [37, 65, 67], first=(-8, 2.25),227last=(-8, -2.25))228_line_embedding(g, [36, 38, 64, 24, 68, 30], first=(-7, 3),229last=(-7, -3))230_line_embedding(g, [35, 39, 63, 25, 59, 29, 11, 5, 55, 23, 69, 31],231first=(-6, 3.5), last=(-6, -3.5))232233# Cube, corners: [9, 15, 21, 27, 45, 51, 57, 61]234_circle_embedding(g, [61, 9], center=(0, -1.5), shift=.2,235radius=4)236_circle_embedding(g, [27, 15], center=(0, -1.5), shift=.7,237radius=4*.707)238_circle_embedding(g, [51, 21], center=(0, 2.5), shift=.2,239radius=4)240_circle_embedding(g, [45, 57], center=(0, 2.5), shift=.7,241radius=4*.707)242243# Cube, subdivision244_line_embedding(g, [21, 22, 43, 44, 45], first=d[21], last=d[45])245_line_embedding(g, [21, 4, 3, 56, 57], first=d[21], last=d[57])246_line_embedding(g, [57, 12, 13, 14, 15], first=d[57], last=d[15])247_line_embedding(g, [15, 6, 7, 8, 9], first=d[15], last=d[9])248_line_embedding(g, [9, 10, 19, 20, 21], first=d[9], last=d[21])249_line_embedding(g, [45, 54, 53, 52, 51], first=d[45], last=d[51])250_line_embedding(g, [51, 50, 49, 58, 57], first=d[51], last=d[57])251_line_embedding(g, [51, 32, 33, 34, 61], first=d[51], last=d[61])252_line_embedding(g, [61, 62, 41, 40, 27], first=d[61], last=d[27])253_line_embedding(g, [9, 0, 1, 26, 27], first=d[9], last=d[27])254_line_embedding(g, [27, 28, 47, 46, 45], first=d[27], last=d[45])255_line_embedding(g, [15, 16, 17, 60, 61], first=d[15], last=d[61])256257# Top vertices258_line_embedding(g, [2, 18, 42, 48], first=(-1, 7), last=(3, 7))259260return g261262elif embedding == 2:263return g264else:265raise ValueError("The value of embedding must be 1 or 2.")266267def WellsGraph():268r"""269Returns the Wells graph.270271For more information on the Wells graph (also called Armanios-Wells graph),272see `this page <http://www.win.tue.nl/~aeb/graphs/Wells.html>`_.273274The implementation follows the construction given on page 266 of275[BCN89]_. This requires to create intermediate graphs and run a small276isomorphism test, while everything could be replaced by a pre-computed list277of edges : I believe that it is better to keep "the recipe" in the code,278however, as it is quite unlikely that this could become the most279time-consuming operation in any sensible algorithm, and .... "preserves280knowledge", which is what open-source software is meant to do.281282EXAMPLES::283284sage: g = graphs.WellsGraph(); g285Wells graph: Graph on 32 vertices286sage: g.order()28732288sage: g.size()28980290sage: g.girth()2915292sage: g.diameter()2934294sage: g.chromatic_number()2954296sage: g.is_regular(k=5)297True298299REFERENCES:300301.. [BCN89] A. E. Brouwer, A. M. Cohen, A. Neumaier,302Distance-Regular Graphs,303Springer, 1989.304"""305from platonic_solids import DodecahedralGraph306from basic import CompleteBipartiteGraph307308# Following the construction from the book "Distance-regular graphs"309dodecahedron = DodecahedralGraph()310311# Vertices at distance 3 in the Dodecahedron312distance3 = dodecahedron.distance_graph([3])313314# Building the graph whose line graph is the dodecahedron.315b = CompleteBipartiteGraph(5,5)316b.delete_edges([(0,5), (1,6), (2,7), (3,8), (4,9)])317318# Computing the isomorphism between the two319b = b.line_graph(labels = False)320_, labels = distance3.is_isomorphic(b, certify = True)321322# The relabeling that the books claims to exist.323for v,new_name in labels.items():324x,y = new_name325labels[v] = (x%5,y%5)326327dodecahedron.relabel(labels)328329# Checking that the above computations indeed produces a good labeling.330for u in dodecahedron:331for v in dodecahedron:332if u == v:333continue334335if (u[0] != v[0]) and (u[1] != v[1]):336continue337338if dodecahedron.distance(u,v) != 3:339raise ValueError("There is something wrong going on !")340341# The graph we will return, starting from the dodecahedron342g = dodecahedron343344# Good ! Now adding 12 new vertices345for i in range(5):346g.add_edge((i,'+'),('inf','+'))347g.add_edge((i,'-'),('inf','-'))348for k in range(5):349if k == i:350continue351g.add_edge((i,'+'),(i,k))352g.add_edge((i,'-'),(k,i))353354g.name("Wells graph")355356# Giving our graph a "not-so-bad" layout357g.relabel({358(1, 3): 8, (3, 0): 18, (3, '+'): 22, (2, 1): 13,359(1, '+'): 10, (0, 3): 2, (2, '+'): 16, ('inf', '-'): 31,360(4, 0): 24, (1, 2): 7, (4, '+'): 28, (0, '-'): 5,361(0, 4): 3, (4, 1): 25, (2, '-'): 17, (3, 2): 20,362(3, '-'): 23, (1, '-'): 11, (1, 4): 9, (2, 3): 14,363('inf', '+'): 30, (4, 2): 26, (1, 0): 6, (0, 1): 0,364(3, 1): 19, (0, 2): 1, (2, 0): 12, (4, '-'): 29,365(0, '+'): 4, (4, 3): 27, (3, 4): 21, (2, 4): 15})366367p = [(1, 29, 20, 13, 12, 28, 14, 7),368(2, 5, 30, 23, 18, 4, 31, 22),369(3, 17, 21, 9, 24, 16, 27, 25),370(6, 10, 8, 15, 0, 11, 19, 26)]371372from sage.graphs.graph_plot import _circle_embedding373_circle_embedding(g, p[0], radius = 1)374_circle_embedding(g, p[1], radius = .9)375_circle_embedding(g, p[2], radius = .8)376_circle_embedding(g, p[3], radius = .7)377378return g379380381def HallJankoGraph(from_string=True):382r"""383Returns the Hall-Janko graph.384385For more information on the Hall-Janko graph, see its386:wikipedia:`Wikipedia page <Hall-Janko_graph>`.387388The construction used to generate this graph in Sage is by389a 100-point permutation representation of the Janko group `J_2`,390as described in version 3 of the ATLAS of Finite Group391representations, in particular on the page `ATLAS: J2392-- Permutation representation on 100 points393<http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0>`_.394395INPUT:396397- ``from_string`` (boolean) -- whether to build the graph from398its sparse6 string or through GAP. The two methods return the399same graph though doing it through GAP takes more time. It is400set to ``True`` by default.401402EXAMPLES::403404sage: g = graphs.HallJankoGraph()405sage: g.is_regular(36)406True407sage: g.is_vertex_transitive()408True409410Is it really strongly regular with parameters 14, 12? ::411412sage: nu = set(g.neighbors(0))413sage: for v in range(1, 100):414....: if v in nu:415....: expected = 14416....: else:417....: expected = 12418....: nv = set(g.neighbors(v))419....: nv.discard(0)420....: if len(nu & nv) != expected:421....: print "Something is wrong here!!!"422....: break423424Some other properties that we know how to check::425426sage: g.diameter()4272428sage: g.girth()4293430sage: factor(g.characteristic_polynomial())431(x - 36) * (x - 6)^36 * (x + 4)^63432433TESTS::434435sage: gg = graphs.HallJankoGraph(from_string=False) # long time436sage: g == gg # long time437True438"""439440string = (":~?@c__E@?g?A?w?A@GCA_?CA`OWF`W?EAW?@?_OD@_[GAgcIaGGB@OcIA"441"wCE@o_K_?GB@?WGAouC@OsN_?GB@O[GB`A@@_e?@OgLB_{Q_?GC@O[GAOs"442"OCWGBA?kKBPA@?_[KB_{OCPKT`o_RD`]A?o[HBOwODW?DA?cIB?wRDP[X`"443"ogKB_{QD@]B@o_KBPWXE`mC@o_JB?{PDPq@?oWGA_{OCPKTDp_YEwCA@_c"444"IBOwOC`OX_OGB@?WPDPcYFg?C@_gKBp?SE@cYF`{_`?SGAOoOC`_\\FwCE"445"A?gKBO{QD@k[FqI??_OFA_oQE@k\\Fq?`GgCB@pGRD@_XFP{a_?SE@ocIA"446"ooNCPOUEqU@?oODA?cJB_{UEqYC@_kLC@CREPk]GAGbHgCA@?SMBpCSD`["447"YFq?`Ga]BA?gPC`KSD`_\\Fa?cHWGB@?[IAooPD`[WF@s^HASeIg?@@OcP"448"C`KYF@w^GQ[h`O[HAooMC@CQCpSVEPk\\GaSeIG?FA?kLB_{OC`OVE@cYG"449"QUA@?WLBp?PC`KVEqKgJg?DA?sMBpCSDP[WEQKfIay@?_KD@_[GC`SUE@k"450"[FaKdHa[k_?OLC@CRD@WVEpo^HAWfIAciIqoo_?CB@?kMCpOUE`o\\GAKg"451"IQgq_?GD@_[GB?{OCpWVE@cYFACaHAWhJR?q_?CC@_kKBpC\\GACdHa[kJ"452"a{o_?CA?oOFBpGRD@o\\GaKdIQonKrOt_?WHA`?PC`KTD`k]FqSeIaolJr"453"CqLWCA@OkKCPGRDpcYGAKdIAgjJAsmJr?t__OE@ogJB_{XEps`HA[gIQwn"454"KWKGAOoMBpGUE`k[Fa?aHqckJbSuLw?@?_SHA_kLC@OTFPw^GaOkLg?B@?"455"[HA_{PDP_XFaCbHa[gIqooKRWx_?CFBpOTE@cZFPw^GACcHQgoKrSvMwWG"456"BOwQCp_YFP{`HASfJAwnKRSx_OSSDP[WEq?aGqSfIQsoKR_zNWCE@o_HA_"457"sREPg^GAGcHQWfIAciKbOxNg?A@__IAooMC`KTD`g\\GAKcIasoKrOtLb["458"wMbyCA?cKBp?TD`[WE`s^GQGbHqcjJrK{NRw~_oODA?sNC@CQCpOZF@s]G"459"QOfIaolJrGsLbk}_?OFA_sRD@SVE`k[HQcjJa{qLb[xMb|?_OOFA?cIAos"460"RDP_ZFa?aGqOfIAsuMbk{Ns@@OsQAA_sPDPWXE`o\\FqKdIQkkJrCuLr_x"461"Mro}NsDAPG?@@OWFApKUE@o`IQolKRKsLrc|NsQC@OWGAOgJCpOWE`o_GQ"462"KiIqwnKr_~OcLCPS]A?oWHA_oMBpKSDP[\\FagjKBWxMbk{OSQ@@O_IAoo"463"LBpCSD`g\\FaGbHQWgIQgmKRKwMRl?PgGC@OWHB@KSE@c[FqCaGqSeIAkk"464"KBCqLBSuMBpGQWCA@?cKBOwRDPWVE@k^GqOfJr?pKbKtLrs}OSHDQwKIBO"465"wPD@WWEQ?`HQWfIQglKBOtLbo}Ns@@OsTE_?kLCpWWHA[gIqomKBGwMRgz"466"NBw~OSPDPc\\H_?CFAOoLCPSVE`o\\GAOeJAwpKbKtMrx?Qcq??OKFA?gJ"467"B`?QDpcYEpo]FqKfIAgjJB?qKr_{NS@A__SE@o_HBO{PC`OTD`{_HaciIq"468"{vMbt?OcPFQCeB@?SKBOwRD@SXE`k[FPw`HQ_lKRKxNRxBPC\\HQclK_?K"469"EB?sOC`OTDa?`GqWgJRCrNBw~OSHFQStMRtDQ_?KC@OoQE`k_GaOdHa[gI"470"q{tMBg|Nb|?OcPMSDDQSwCB@_cJB_{OCpOVFP{dHa[jJQwqKrk}NsHBQCd"471"MRtMA?oSEA_wPDp_YEpo]GAOeIq{pLBk}NsLEQCtNTDU??OKEA_oLC@[[G"472"aKnKBOtLbk~OCPFQStNSDLSTgGKC@GSD`[WEpw_GQGcIAciJAwpKb_xMbk"473"~QShJRc|R`_wNCPcZF@s^GAGbHA_hJR?qKrOvMRg|NsDEPsxTTgCB@?gJB"474"?sMC@CUDp_]FqCaHQcjJQwtLrhCPS\\IRCtQTw?B@?SHA_wPC`_aGqOiJa"475"{oKRKvMRpFQChKRtXVUTi??ocNC@KUE@cYFaGdHa_mJrKsLb[yMro|OcXI"476"RdPTTddZaOgJB@?UEPk[FQCfIaolJrSvMBczNR|AOsXFQCtOTtaB@?WGAP"477"?TEPo\\GAGdHqgmKBCqLR[xMb|?PC`HQs|TTt`XUtu@?o[HB?sNCPGXF@{"478"_GQKcIqolJb_yNCLDPs`MRtDRTTdYUwSEA?kLB`CWF@s]FqGgIqooLRgzN"479"RxFQSlMSDDQTDXVUTi@?_KDAOoLBpKUEQOfIa{oLB_xMrt?Os\\HQcpMST"480"HSTtl[VT}A@ocJBOwSD`_XEpo_Ha_mJrKtLbgzNSTGQspLRtDUUDp\\WG["481"HB`CQCp[WFQGgIQgkJQ{rLbc{Nc@APsdLRt@PSt\\WUtt_Wn")482483if from_string:484g = Graph(string, loops = False, multiedges = False)485else:486487# The following construction is due to version 3 of the ATLAS of488# Finite Group Representations, specifically the page at489# http://brauer.maths.qmul.ac.uk/Atlas/v3/permrep/J2G1-p100B0 .490491from sage.interfaces.gap import gap492gap.eval("g1 := (1,84)(2,20)(3,48)(4,56)(5,82)(6,67)(7,55)(8,41)"493"(9,35)(10,40)(11,78)(12,100)(13,49)(14,37)(15,94)(16,76)"494"(17,19)(18,44)(21,34)(22,85)(23,92)(24,57)(25,75)(26,28)"495"(27,64)(29,90)(30,97)(31,38)(32,68)(33,69)(36,53)(39,61)"496"(42,73)(43,91)(45,86)(46,81)(47,89)(50,93)(51,96)(52,72)"497"(54,74)(58,99)(59,95)(60,63)(62,83)(65,70)(66,88)(71,87)"498"(77,98)(79,80);")499500gap.eval("g2 := (1,80,22)(2,9,11)(3,53,87)(4,23,78)(5,51,18)"501"(6,37,24)(8,27,60)(10,62,47)(12,65,31)(13,64,19)"502"(14,61,52)(15,98,25)(16,73,32)(17,39,33)(20,97,58)"503"(21,96,67)(26,93,99)(28,57,35)(29,71,55)(30,69,45)"504"(34,86,82)(38,59,94)(40,43,91)(42,68,44)(46,85,89)"505"(48,76,90)(49,92,77)(50,66,88)(54,95,56)(63,74,72)"506"(70,81,75)(79,100,83);")507508gap.eval("G := Group([g1,g2]);")509edges = gap('Orbit(G,[1,5],OnSets)').sage()510g = Graph([(int(u), int(v)) for u,v in edges])511g.relabel()512513_circle_embedding(g, range(100))514g.name("Hall-Janko graph")515return g516517def Balaban10Cage(embedding=1):518r"""519Returns the Balaban 10-cage.520521The Balaban 10-cage is a 3-regular graph with 70 vertices and522105 edges. See its :wikipedia:`Wikipedia page523<Balaban_10-cage>`.524525The default embedding gives a deeper understanding of the526graph's automorphism group. It is divided into 4 layers (each527layer being a set of points at equal distance from the drawing's528center). From outside to inside:529530- L1: The outer layer (vertices which are the furthest from the531origin) is actually the disjoint union of two cycles of length53210.533534- L2: The second layer is an independent set of 20 vertices.535536- L3: The third layer is a matching on 10 vertices.537538- L4: The inner layer (vertices which are the closest from the539origin) is also the disjoint union of two cycles of length 10.540541This graph is not vertex-transitive, and its vertices are542partitioned into 3 orbits: L2, L3, and the union of L1 of L4543whose elements are equivalent.544545INPUT:546547- ``embedding`` -- two embeddings are available, and can be548selected by setting ``embedding`` to be either 1 or 2.549550EXAMPLES::551552sage: g = graphs.Balaban10Cage()553sage: g.girth()55410555sage: g.chromatic_number()5562557sage: g.diameter()5586559sage: g.is_hamiltonian()560True561sage: g.show(figsize=[10,10]) # long time562563TESTS::564565sage: graphs.Balaban10Cage(embedding='foo')566Traceback (most recent call last):567...568ValueError: The value of embedding must be 1 or 2.569"""570571L = [-9, -25, -19, 29, 13, 35, -13, -29, 19, 25, 9, -29, 29, 17, 33,57221, 9,-13, -31, -9, 25, 17, 9, -31, 27, -9, 17, -19, -29, 27,573-17, -9, -29, 33, -25,25, -21, 17, -17, 29, 35, -29, 17, -17,57421, -25, 25, -33, 29, 9, 17, -27, 29, 19, -17, 9, -27, 31, -9,575-17, -25, 9, 31, 13, -9, -21, -33, -17, -29, 29]576577from sage.graphs.generators.families import LCFGraph578g = LCFGraph(70, L, 1)579g.name("Balaban 10-cage")580581if embedding == 2:582return g583elif embedding != 1:584raise ValueError("The value of embedding must be 1 or 2.")585586L3 = [5, 24, 35, 46, 29, 40, 51, 34, 45, 56]587_circle_embedding(g, L3, center=(0,0), radius = 4.3)588589L2 = [6, 4, 23, 25, 60, 36, 1, 47, 28, 30, 39, 41, 50, 52, 33, 9, 44,59020, 55, 57]591_circle_embedding(g, L2, center=(0,0), radius = 5, shift=-.5)592593594L1a = [69, 68, 67, 66, 65, 64, 63, 62, 61, 0]595L1b = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10]596_circle_embedding(g, L1a, center=(0,0), radius = 6, shift = 3.25)597_circle_embedding(g, L1b, center=(0,0), radius = 6, shift = -1.25)598599L4a = [37, 2, 31, 38, 53, 32, 21, 54, 3, 22]600_circle_embedding(g, L4a, center=(0,0), radius = 3, shift = 1.9)601602L4b = [26, 59, 48, 27, 42, 49, 8, 43, 58, 7]603_circle_embedding(g, L4b, center=(0,0), radius = 3, shift = 1.1)604605return g606607def Balaban11Cage(embedding = 1):608r"""609Returns the Balaban 11-cage.610611For more information, see this :wikipedia:`Wikipedia article on612the Balaban 11-cage <Balaban_11-cage>`.613614INPUT:615616- ``embedding`` -- three embeddings are available, and can be617selected by setting ``embedding`` to be 1, 2, or 3.618619- The first embedding is the one appearing on page 9 of the620Fifth Annual Graph Drawing Contest report [FAGDC]_. It621separates vertices based on their eccentricity (see622:meth:`eccentricity()623<sage.graphs.generic_graph.GenericGraph.eccentricity>`).624625- The second embedding has been produced just for Sage and is626meant to emphasize the automorphism group's 6 orbits.627628- The last embedding is the default one produced by the629:meth:`LCFGraph` constructor.630631.. NOTE::632633The vertex labeling changes according to the value of634``embedding=1``.635636EXAMPLES:637638Basic properties::639640sage: g = graphs.Balaban11Cage()641sage: g.order()642112643sage: g.size()644168645sage: g.girth()64611647sage: g.diameter()6488649sage: g.automorphism_group().cardinality()65064651652Our many embeddings::653654sage: g1 = graphs.Balaban11Cage(embedding=1)655sage: g2 = graphs.Balaban11Cage(embedding=2)656sage: g3 = graphs.Balaban11Cage(embedding=3)657sage: g1.show(figsize=[10,10]) # long time658sage: g2.show(figsize=[10,10]) # long time659sage: g3.show(figsize=[10,10]) # long time660661Proof that the embeddings are the same graph::662663sage: g1.is_isomorphic(g2) # g2 and g3 are obviously isomorphic664True665666TESTS::667668sage: graphs.Balaban11Cage(embedding='xyzzy')669Traceback (most recent call last):670...671ValueError: The value of embedding must be 1, 2, or 3.672673REFERENCES:674675.. [FAGDC] Fifth Annual Graph Drawing Contest676P. Eaded, J. Marks, P.Mutzel, S. North677http://www.merl.com/papers/docs/TR98-16.pdf678"""679if embedding == 1:680pos_dict = {}681for j in range(8):682for i in range(8):683pos_dict[str(j) + str(i)]= [6840.8 * float(cos(2*((8*j + i)*pi/64 + pi/128))),6850.8 * float(sin(2*((8*j + i)*pi/64 + pi/128)))686]687for i in range(4):688pos_dict['1' + str(j) + str(i)] = [6891.1 * float(cos(2*((4*j + i)*pi/32 + pi/64))),6901.1 * float(sin(2*((4*j + i)*pi/32 + pi/64)))691]692for i in range(2):693pos_dict['1' + str(j) + str(i + 4)] = [6941.4 * float(cos(2*((2*j + i)*pi/16 + pi/32))),6951.4 * float(sin(2*((2*j + i)*pi/16 + pi/32)))696]697698edge_dict = {699"00": ["11"], "01": ["10"], "02": ["53"], "03": ["52"],700"11": ["20"], "10": ["21"], "53": ["22"], "52": ["23"],701"20": ["31"], "21": ["30"], "22": ["33"], "23": ["32"],702"31": ["40"], "30": ["41"], "33": ["43"], "32": ["42"],703"40": ["50"], "41": ["51"], "43": ["12"], "42": ["13"],704"50": ["61"], "51": ["60"], "12": ["63"], "13": ["62"],705"61": ["70"], "60": ["71"], "63": ["72"], "62": ["73"],706"70": ["01"], "71": ["00"], "72": ["03"], "73": ["02"],707708"04": ["35"], "05": ["34"], "06": ["37"], "07": ["36"],709"35": ["64"], "34": ["65"], "37": ["66"], "36": ["67"],710"64": ["55"], "65": ["54"], "66": ["17"], "67": ["16"],711"55": ["45"], "54": ["44"], "17": ["46"], "16": ["47"],712"45": ["74"], "44": ["75"], "46": ["76"], "47": ["77"],713"74": ["25"], "75": ["24"], "76": ["27"], "77": ["26"],714"25": ["14"], "24": ["15"], "27": ["56"], "26": ["57"],715"14": ["05"], "15": ["04"], "56": ["07"], "57": ["06"],716717"100": ["03", "04"], "110": ["10", "12"],718"101": ["01", "06"], "111": ["11", "13"],719"102": ["00", "07"], "112": ["14", "16"],720"103": ["02", "05"], "113": ["15", "17"],721722"120": ["22", "24"], "130": ["33", "36"],723"121": ["20", "26"], "131": ["32", "37"],724"122": ["21", "27"], "132": ["31", "34"],725"123": ["23", "25"], "133": ["30", "35"],726727"140": ["43", "45"], "150": ["50", "52"],728"141": ["40", "46"], "151": ["51", "53"],729"142": ["41", "47"], "152": ["54", "56"],730"143": ["42", "44"], "153": ["55", "57"],731732"160": ["60", "66"], "170": ["73", "76"],733"161": ["63", "65"], "171": ["72", "77"],734"162": ["62", "64"], "172": ["71", "74"],735"163": ["61", "67"], "173": ["70", "75"],736737"104": ["100", "102", "105"], "114": ["110", "111", "115"],738"105": ["101", "103", "104"], "115": ["112", "113", "114"],739740"124": ["120", "121", "125"], "134": ["130", "131", "135"],741"125": ["122", "123", "124"], "135": ["132", "133", "134"],742743"144": ["140", "141", "145"], "154": ["150", "151", "155"],744"145": ["142", "143", "144"], "155": ["152", "153", "154"],745746"164": ["160", "161", "165"], "174": ["170", "171", "175"],747"165": ["162", "163", "164"], "175": ["172", "173", "174"]748}749750return Graph(edge_dict, pos=pos_dict, name="Balaban 11-cage")751752elif embedding == 2 or embedding == 3:753L = [44, 26, -47, -15, 35, -39, 11, -27, 38, -37, 43, 14, 28, 51,754-29, -16, 41, -11, -26, 15, 22, -51, -35, 36, 52, -14, -33,755-26, -46, 52, 26, 16, 43, 33, -15, 17, -53, 23, -42, -35, -28,75630, -22, 45, -44, 16, -38, -16, 50, -55, 20, 28, -17, -43,75747, 34, -26, -41, 11, -36, -23, -16, 41, 17, -51, 26, -33,75847, 17, -11, -20, -30, 21, 29, 36, -43, -52, 10, 39, -28, -17,759-52, 51, 26, 37, -17, 10, -10, -45, -34, 17, -26, 27, -21,76046, 53, -10, 29, -50, 35, 15, -47, -29, -41, 26, 33, 55, -17,76142, -26, -36, 16]762763from sage.graphs.generators.families import LCFGraph764g = LCFGraph(112, L, 1)765g.name("Balaban 11-cage")766767if embedding == 3:768return g769770v1 = [34, 2, 54, 43, 66, 20, 89, 100, 72, 76, 6, 58, 16, 78, 74,77170, 36, 94, 27, 25, 10, 8, 45, 60, 14, 64, 80, 82, 109, 107,77249, 98]773v2 = [88, 3, 19, 55, 67, 42, 101, 33, 77, 5, 17, 57, 69, 71, 73,77475, 11, 61, 28, 9, 37, 26, 46, 95, 13, 63, 81, 83, 108, 106,77548, 97]776l1 = [35, 93, 1, 24, 53, 7, 44, 59, 15, 65, 79, 21, 110, 90, 50,77799]778l2 = [87, 4, 18, 56, 68, 41, 102, 32, 12, 62, 29, 84, 38, 105, 47,77996]780781d = g.get_pos()782for i,v in enumerate(v1):783d[v] = (-2, 16.5-i)784785for i,v in enumerate(l1):786d[v] = (-10, 8-i)787788for i,v in enumerate(l2):789d[v] = (10, 8.5-i)790791for i,v in enumerate(v2):792d[v] = (2, 16.5-i)793794for i,v in enumerate([0, 111, 92, 91, 52, 51, 23, 22]):795d[v] = (-20, 14.5-4*i)796797for i,v in enumerate([104, 103, 86, 85, 40, 39, 31, 30]):798d[v] = (20, 14.5-4*i)799800return g801802else:803raise ValueError("The value of embedding must be 1, 2, or 3.")804805def BidiakisCube():806r"""807Returns the Bidiakis cube.808809For more information, see this810`Wikipedia article on the Bidiakis cube <http://en.wikipedia.org/wiki/Bidiakis_cube>`_.811812EXAMPLES:813814The Bidiakis cube is a 3-regular graph having 12 vertices and 18815edges. This means that each vertex has a degree of 3. ::816817sage: g = graphs.BidiakisCube(); g818Bidiakis cube: Graph on 12 vertices819sage: g.show() # long time820sage: g.order()82112822sage: g.size()82318824sage: g.is_regular(3)825True826827It is a Hamiltonian graph with diameter 3 and girth 4::828829sage: g.is_hamiltonian()830True831sage: g.diameter()8323833sage: g.girth()8344835836It is a planar graph with characteristic polynomial837`(x - 3) (x - 2) (x^4) (x + 1) (x + 2) (x^2 + x - 4)^2` and838chromatic number 3::839840sage: g.is_planar()841True842sage: bool(g.characteristic_polynomial() == expand((x - 3) * (x - 2) * (x^4) * (x + 1) * (x + 2) * (x^2 + x - 4)^2))843True844sage: g.chromatic_number()8453846"""847edge_dict = {8480:[1,6,11], 1:[2,5], 2:[3,10], 3:[4,9], 4:[5,8],8495:[6], 6:[7], 7:[8,11], 8:[9], 9:[10], 10:[11]}850pos_dict = {8510: [0, 1],8521: [0.5, 0.866025403784439],8532: [0.866025403784439, 0.500000000000000],8543: [1, 0],8554: [0.866025403784439, -0.5],8565: [0.5, -0.866025403784439],8576: [0, -1],8587: [-0.5, -0.866025403784439],8598: [-0.866025403784439, -0.5],8609: [-1, 0],86110: [-0.866025403784439, 0.5],86211: [-0.5, 0.866025403784439]}863return Graph(edge_dict, pos=pos_dict, name="Bidiakis cube")864865def BiggsSmithGraph(embedding=1):866r"""867Returns the Biggs-Smith graph.868869For more information, see this :wikipedia:`Wikipedia article on870the Biggs-Smith graph <Biggs-Smith_graph>`.871872INPUT:873874- ``embedding`` -- two embeddings are available, and can be875selected by setting ``embedding`` to be 1 or 2.876877EXAMPLES:878879Basic properties::880881sage: g = graphs.BiggsSmithGraph()882sage: g.order()883102884sage: g.size()885153886sage: g.girth()8879888sage: g.diameter()8897890sage: g.automorphism_group().cardinality()8912448892sage: g.show(figsize=[10, 10]) # long time893894The other embedding::895896sage: graphs.BiggsSmithGraph(embedding=2).show()897898TESTS::899900sage: graphs.BiggsSmithGraph(embedding='xyzzy')901Traceback (most recent call last):902...903ValueError: The value of embedding must be 1 or 2.904905"""906L = [16, 24, -38, 17, 34, 48, -19, 41, -35, 47, -20, 34, -36,90721, 14, 48, -16, -36, -43, 28, -17, 21, 29, -43, 46, -24,90828, -38, -14, -50, -45, 21, 8, 27, -21, 20, -37, 39, -34,909-44, -8, 38, -21, 25, 15, -34, 18, -28, -41, 36, 8, -29,910-21, -48, -28, -20, -47, 14, -8, -15, -27, 38, 24, -48, -18,91125, 38, 31, -25, 24, -46, -14, 28, 11, 21, 35, -39, 43, 36,912-38, 14, 50, 43, 36, -11, -36, -24, 45, 8, 19, -25, 38, 20,913-24, -14, -21, -8, 44, -31, -38, -28, 37]914915from sage.graphs.generators.families import LCFGraph916g = LCFGraph(102, L, 1)917g.name("Biggs-Smith graph")918919if embedding == 1:920921orbs = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0],922[17, 101, 25, 66, 20, 38, 53, 89, 48, 75, 56, 92, 45, 78,92334, 28, 63],924[18, 36, 26, 65, 19, 37, 54, 90, 47, 76, 55, 91, 46, 77,92535, 27, 64],926[21, 39, 52, 88, 49, 74, 57, 93, 44, 79, 33, 29, 62, 83,927100, 24, 67],928[22, 97, 51, 96, 50, 95, 58, 94, 59, 80, 60, 81, 61, 82,92999, 23, 98],930[30, 86, 84, 72, 70, 68, 42, 40, 31, 87, 85, 73, 71, 69,93143, 41, 32]]932933# central orbits934_circle_embedding(g, orbs[1], center=(-.4, 0), radius=.2)935_circle_embedding(g, orbs[3], center=(.4, 0), radius=.2, shift=4)936937# lower orbits938_circle_embedding(g, orbs[0], center=(-.9, -.5), radius=.3,939shift=2)940_circle_embedding(g, orbs[2], center=(-.9, .5), radius=.3)941942# upper orbits943_circle_embedding(g, orbs[4], center=(.9, -.5), radius=.3, shift=4)944_circle_embedding(g, orbs[5], center=(.9, .5), radius=.3, shift=-2)945946elif embedding == 2:947pass948else:949raise ValueError("The value of embedding must be 1 or 2.")950951return g952953def BlanusaFirstSnarkGraph():954r"""955Returns the first Blanusa Snark Graph.956957The Blanusa graphs are two snarks on 18 vertices and 27 edges. For more958information on them, see the :wikipedia:`Blanusa_snarks`.959960.. SEEALSO::961962* :meth:`~sage.graphs.graph_generators.GraphGenerators.BlanusaSecondSnarkGraph`.963964EXAMPLES::965966sage: g = graphs.BlanusaFirstSnarkGraph()967sage: g.order()96818969sage: g.size()97027971sage: g.diameter()9724973sage: g.girth()9745975sage: g.automorphism_group().cardinality()9768977"""978g = Graph({17:[4,7,1],0:[5],9793:[8],13:[9],12:[16],98010:[15],11:[6],14:[2]},981name="Blanusa First Snark Graph")982983g.add_cycle(range(17))984_circle_embedding(g, range(17), shift=0.25)985g.get_pos()[17] = (0,0)986return g987988def BlanusaSecondSnarkGraph():989r"""990Returns the second Blanusa Snark Graph.991992The Blanusa graphs are two snarks on 18 vertices and 27 edges. For more993information on them, see the :wikipedia:`Blanusa_snarks`.994995.. SEEALSO::996997* :meth:`~sage.graphs.graph_generators.GraphGenerators.BlanusaFirstSnarkGraph`.998999EXAMPLES::10001001sage: g = graphs.BlanusaSecondSnarkGraph()1002sage: g.order()1003181004sage: g.size()1005271006sage: g.diameter()100741008sage: g.girth()100951010sage: g.automorphism_group().cardinality()101141012"""1013g = Graph({0:[(0,0),(1,4),1],1:[(0,3),(1,1)],(0,2):[(0,5)],1014(0,6):[(0,4)],(0,7):[(0,1)],(1,7):[(1,2)],1015(1,0):[(1,6)],(1,3):[(1,5)]},1016name="Blanusa Second Snark Graph")10171018g.add_cycle([(0,i) for i in range(5)])1019g.add_cycle([(1,i) for i in range(5)])1020g.add_cycle([(0,5),(0,6),(0,7),(1,5),(1,6),(1,7)])10211022_circle_embedding(g,1023[(0,(2*i)%5) for i in range(5)],1024center = (-1.5,0),1025shift = .5)1026_circle_embedding(g,1027[(1,(2*i)%5) for i in range(5)],1028center = (1.5,0))10291030_circle_embedding(g,1031[(0,i) for i in range(5,8)]+[0]*4,1032center = (-1.2,0),1033shift = 2.5,1034radius = 2.2)1035_circle_embedding(g,1036[(1,i) for i in range(5,8)]+[0]*4,1037center = (1.2,0),1038shift = -1,1039radius = 2.2)10401041_circle_embedding(g,[0,1], shift=.5)1042g.relabel()1043return g10441045def BrinkmannGraph():1046r"""1047Returns the Brinkmann graph.10481049For more information, see the1050`Wikipedia article on the Brinkmann graph <http://en.wikipedia.org/wiki/Brinkmann_graph>`_.10511052EXAMPLES:10531054The Brinkmann graph is a 4-regular graph having 21 vertices and 421055edges. This means that each vertex has degree 4. ::10561057sage: G = graphs.BrinkmannGraph(); G1058Brinkmann graph: Graph on 21 vertices1059sage: G.show() # long time1060sage: G.order()1061211062sage: G.size()1063421064sage: G.is_regular(4)1065True10661067It is an Eulerian graph with radius 3, diameter 3, and girth 5. ::10681069sage: G.is_eulerian()1070True1071sage: G.radius()107231073sage: G.diameter()107431075sage: G.girth()1076510771078The Brinkmann graph is also Hamiltonian with chromatic number 4::10791080sage: G.is_hamiltonian()1081True1082sage: G.chromatic_number()1083410841085Its automorphism group is isomorphic to `D_7`::10861087sage: ag = G.automorphism_group()1088sage: ag.is_isomorphic(DihedralGroup(7))1089True1090"""1091edge_dict = {10920: [2,5,7,13],10931: [3,6,7,8],10942: [4,8,9],10953: [5,9,10],10964: [6,10,11],10975: [11,12],10986: [12,13],10997: [15,20],11008: [14,16],11019: [15,17],110210: [16,18],110311: [17,19],110412: [18,20],110513: [14,19],110614: [17,18],110715: [18,19],110816: [19,20],110917: [20]}1110pos_dict = {11110: [0, 4],11121: [3.12732592987212, 2.49395920743493],11132: [3.89971164872729, -0.890083735825258],11143: [1.73553495647023, -3.60387547160968],11154: [-1.73553495647023, -3.60387547160968],11165: [-3.89971164872729, -0.890083735825258],11176: [-3.12732592987212, 2.49395920743493],11187: [0.867767478235116, 1.80193773580484],11198: [1.94985582436365, 0.445041867912629],11209: [1.56366296493606, -1.24697960371747],112110: [0, -2],112211: [-1.56366296493606, -1.24697960371747],112312: [-1.94985582436365, 0.445041867912629],112413: [-0.867767478235116, 1.80193773580484],112514: [0.433883739117558, 0.900968867902419],112615: [0.974927912181824, 0.222520933956314],112716: [0.781831482468030, -0.623489801858733],112817: [0, -1],112918: [-0.781831482468030, -0.623489801858733],113019: [-0.974927912181824, 0.222520933956315],113120: [-0.433883739117558, 0.900968867902419]}1132return Graph(edge_dict, pos=pos_dict, name="Brinkmann graph")11331134def BrouwerHaemersGraph():1135r"""1136Returns the Brouwer-Haemers Graph.11371138The Brouwer-Haemers is the only strongly regular graph of parameters1139`(81,20,1,6)`. It is build in Sage as the Affine Orthogonal graph1140`VO^-(6,3)`. For more information on this graph, see its `corresponding page1141on Andries Brouwer's website1142<http://www.win.tue.nl/~aeb/graphs/Brouwer-Haemers.html>`_.11431144EXAMPLE::11451146sage: g = graphs.BrouwerHaemersGraph()1147sage: g1148Brouwer-Haemers: Graph on 81 vertices11491150It is indeed strongly regular with parameters `(81,20,1,6)`::11511152sage: g.is_strongly_regular(parameters = True) # long time1153(81, 20, 1, 6)11541155Its has as eigenvalues `20,2` and `-7`::11561157sage: set(g.spectrum()) == {20,2,-7}1158True1159"""1160from sage.rings.finite_rings.constructor import FiniteField1161from sage.modules.free_module import VectorSpace1162from sage.matrix.constructor import Matrix1163from sage.matrix.constructor import identity_matrix11641165d = 41166q = 31167F = FiniteField(q,"x")1168V = VectorSpace(F,d)1169M = Matrix(F,identity_matrix(d))1170M[1,1]=-11171G = Graph([map(tuple,V), lambda x,y:(V(x)-V(y))*(M*(V(x)-V(y))) == 0], loops = False)1172G.relabel()1173ordering = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,117418, 19, 20, 21, 22, 23, 24, 25, 26, 48, 49, 50, 51, 52, 53,117545, 46, 47, 30, 31, 32, 33, 34, 35, 27, 28, 29, 39, 40, 41,117642, 43, 44, 36, 37, 38, 69, 70, 71, 63, 64, 65, 66, 67, 68,117778, 79, 80, 72, 73, 74, 75, 76, 77, 60, 61, 62, 54, 55, 56,117857, 58, 59]1179_circle_embedding(G, ordering)1180G.name("Brouwer-Haemers")1181return G11821183def BuckyBall():1184r"""1185Create the Bucky Ball graph.11861187This graph is a 3-regular 60-vertex planar graph. Its vertices1188and edges correspond precisely to the carbon atoms and bonds1189in buckminsterfullerene. When embedded on a sphere, its 121190pentagon and 20 hexagon faces are arranged exactly as the1191sections of a soccer ball.11921193EXAMPLES:11941195The Bucky Ball is planar. ::11961197sage: g = graphs.BuckyBall()1198sage: g.is_planar()1199True12001201The Bucky Ball can also be created by extracting the 1-skeleton1202of the Bucky Ball polyhedron, but this is much slower. ::12031204sage: g = polytopes.buckyball().vertex_graph()1205sage: g.remove_loops()1206sage: h = graphs.BuckyBall()1207sage: g.is_isomorphic(h)1208True12091210The graph is returned along with an attractive embedding. ::12111212sage: g = graphs.BuckyBall()1213sage: g.plot(vertex_labels=False, vertex_size=10).show() # long time1214"""1215edges = [(0, 2), (0, 48), (0, 59), (1, 3), (1, 9), (1, 58),1216(2, 3), (2, 36), (3, 17), (4, 6), (4, 8), (4, 12),1217(5, 7), (5, 9), (5, 16), (6, 7), (6, 20), (7, 21),1218(8, 9), (8, 56), (10, 11), (10, 12), (10, 20), (11, 27),1219(11, 47), (12, 13), (13, 46), (13, 54), (14, 15), (14, 16),1220(14, 21), (15, 25), (15, 41), (16, 17), (17, 40), (18, 19),1221(18, 20), (18, 26), (19, 21), (19, 24), (22, 23), (22, 31),1222(22, 34), (23, 25), (23, 38), (24, 25), (24, 30), (26, 27),1223(26, 30), (27, 29), (28, 29), (28, 31), (28, 35), (29, 44),1224(30, 31), (32, 34), (32, 39), (32, 50), (33, 35), (33, 45),1225(33, 51), (34, 35), (36, 37), (36, 40), (37, 39), (37, 52),1226(38, 39), (38, 41), (40, 41), (42, 43), (42, 46), (42, 55),1227(43, 45), (43, 53), (44, 45), (44, 47), (46, 47), (48, 49),1228(48, 52), (49, 53), (49, 57), (50, 51), (50, 52), (51, 53),1229(54, 55), (54, 56), (55, 57), (56, 58), (57, 59), (58, 59)1230]1231g = Graph()1232g.add_edges(edges)1233g.name("Bucky Ball")12341235pos = {12360 : (1.00000000000000, 0.000000000000000),12371 : (-1.00000000000000, 0.000000000000000),12382 : (0.500000000000000, 0.866025403784439),12393 : (-0.500000000000000, 0.866025403784439),12404 : (-0.252886764483159, -0.146004241548845),12415 : (-0.368953972399043, 0.0928336233191176),12426 : (-0.217853192651371, -0.0480798425451855),12437 : (-0.255589950938772, 0.0495517623332213),12448 : (-0.390242139418333, -0.225306404242310),12459 : (-0.586398703939125, -0.0441575936410641),124610: (-0.113926229169631, -0.101751920396670),124711: (-0.0461308635969359, -0.0928422349110366),124812: (-0.150564961379772, -0.164626477859040),124913: (-0.0848818904865275, -0.246123271631605),125014: (-0.170708060452244, 0.196571509298384),125115: (-0.0672882312715990, 0.212706320404226),125216: (-0.264873262319233, 0.273106701265196),125317: (-0.254957754106411, 0.529914971178085),125418: (-0.103469165775548, 0.00647061768205703),125519: (-0.113590051906687, 0.0655812470455896),125620: (-0.145082862532183, -0.0477870484199328),125721: (-0.179962687765901, 0.103901506225732),125822: (0.0573383021786124, 0.0863716172289798),125923: (0.0311566333625530, 0.149538968816603),126024: (-0.0573383021786121, 0.0863716172289799),126125: (-0.0311566333625527, 0.149538968816603),126226: (-0.0517345828877740, 0.00161765442051429),126327: (-0.0244663616211774, -0.0456122902452611),126428: (0.0517345828877743, 0.00161765442051431),126529: (0.0244663616211777, -0.0456122902452611),126630: (-0.0272682212665964, 0.0439946358247470),126731: (0.0272682212665968, 0.0439946358247470),126832: (0.179962687765901, 0.103901506225732),126933: (0.145082862532184, -0.0477870484199329),127034: (0.113590051906687, 0.0655812470455895),127135: (0.103469165775548, 0.00647061768205698),127236: (0.254957754106411, 0.529914971178085),127337: (0.264873262319233, 0.273106701265196),127438: (0.0672882312715993, 0.212706320404226),127539: (0.170708060452245, 0.196571509298384),127640: (1.59594559789866e-16, 0.450612808484620),127741: (2.01227923213310e-16, 0.292008483097691),127842: (0.0848818904865278, -0.246123271631605),127943: (0.150564961379773, -0.164626477859040),128044: (0.0461308635969362, -0.0928422349110366),128145: (0.113926229169631, -0.101751920396670),128246: (1.66533453693773e-16, -0.207803012451463),128347: (1.80411241501588e-16, -0.131162494091179),128448: (0.586398703939126, -0.0441575936410641),128549: (0.390242139418333, -0.225306404242310),128650: (0.255589950938772, 0.0495517623332212),128751: (0.217853192651372, -0.0480798425451855),128852: (0.368953972399044, 0.0928336233191175),128953: (0.252886764483159, -0.146004241548845),129054: (-0.104080710079810, -0.365940324584313),129155: (0.104080710079811, -0.365940324584313),129256: (-0.331440949832714, -0.485757377537020),129357: (0.331440949832715, -0.485757377537021),129458: (-0.500000000000000, -0.866025403784438),129559: (0.500000000000000, -0.866025403784439)1296}12971298g.set_pos(pos)12991300return g13011302def DoubleStarSnark():1303r"""1304Returns the double star snark.13051306The double star snark is a 3-regular graph on 30 vertices. See1307the :wikipedia:`Wikipedia page on the double star snark1308<Double-star_snark>`.13091310EXAMPLES::13111312sage: g = graphs.DoubleStarSnark()1313sage: g.order()1314301315sage: g.size()1316451317sage: g.chromatic_number()131831319sage: g.is_hamiltonian()1320False1321sage: g.automorphism_group().cardinality()1322801323sage: g.show()1324"""13251326d = { 0: [1, 14, 15]1327, 1: [0, 2, 11]1328, 2: [1, 3, 7]1329, 3: [2, 4, 18]1330, 4: [3, 5, 14]1331, 5: [10, 4, 6]1332, 6: [5, 21, 7]1333, 7: [8, 2, 6]1334, 8: [9, 13, 7]1335, 9: [24, 8, 10]1336, 10: [9, 11, 5]1337, 11: [1, 10, 12]1338, 12: [11, 27, 13]1339, 13: [8, 12, 14]1340, 14: [0, 4, 13]1341, 15: [0, 16, 29]1342, 16: [15, 20, 23]1343, 17: [25, 18, 28]1344, 18: [3, 17, 19]1345, 19: [18, 26, 23]1346, 20: [16, 28, 21]1347, 21: [20, 6, 22]1348, 22: [26, 21, 29]1349, 23: [16, 24, 19]1350, 24: [25, 9, 23]1351, 25: [24, 17, 29]1352, 26: [27, 19, 22]1353, 27: [12, 26, 28]1354, 28: [17, 27, 20]1355, 29: [25, 22, 15]1356}13571358g = Graph(d, pos={}, name="Double star snark")1359_circle_embedding(g, range(15), radius=2)1360_circle_embedding(g, range(15, 30), radius=1.4)13611362return g13631364def MeredithGraph():1365r"""1366Returns the Meredith Graph13671368The Meredith Graph is a 4-regular 4-connected non-hamiltonian graph. For1369more information on the Meredith Graph, see the :wikipedia:`Meredith_graph`.13701371EXAMPLES::13721373sage: g = graphs.MeredithGraph()1374sage: g.is_regular(4)1375True1376sage: g.order()1377701378sage: g.size()13791401380sage: g.radius()138171382sage: g.diameter()138381384sage: g.girth()138541386sage: g.chromatic_number()138731388sage: g.is_hamiltonian() # long time1389False1390"""1391g = Graph(name="Meredith Graph")1392g.add_vertex(0)13931394# Edges between copies of K_{4,3}1395for i in range(5):1396g.add_edge(('outer',i,3),('outer',(i+1)%5,0))1397g.add_edge(('inner',i,3),('inner',(i+2)%5,0))1398g.add_edge(('outer',i,1),('inner',i ,1))1399g.add_edge(('outer',i,2),('inner',i ,2))14001401# Edges inside of the K_{4,3}s.1402for i in range(5):1403for j in range(4):1404for k in range(3):1405g.add_edge(('inner',i,j),('inner',i,k+4))1406g.add_edge(('outer',i,j),('outer',i,k+4))14071408_circle_embedding(g, sum([[('outer',i,j) for j in range(4)]+10*[0] for i in range(5)],[]), radius = 1, shift = 2)1409_circle_embedding(g, sum([[('outer',i,j) for j in range(4,7)]+10*[0] for i in range(5)],[]), radius = 1.2, shift = 2.2)1410_circle_embedding(g, sum([[('inner',i,j) for j in range(4)]+7*[0] for i in range(5)],[]), radius = .6, shift = 1.24)1411_circle_embedding(g, sum([[('inner',i,j) for j in range(4,7)]+5*[0] for i in range(5)],[]), radius = .4, shift = 1.05)14121413g.delete_vertex(0)1414g.relabel()1415return g14161417def KittellGraph():1418r"""1419Returns the Kittell Graph.14201421For more information, see the `Wolfram page about the Kittel Graph1422<http://mathworld.wolfram.com/KittellGraph.html>`_.14231424EXAMPLES::14251426sage: g = graphs.KittellGraph()1427sage: g.order()1428231429sage: g.size()1430631431sage: g.radius()143231433sage: g.diameter()143441435sage: g.girth()143631437sage: g.chromatic_number()143841439"""1440g = Graph({0: [1, 2, 4, 5, 6, 7], 1: [0, 2, 7, 10, 11, 13],14412: [0, 1, 11, 4, 14], 3: [16, 12, 4, 5, 14], 4: [0, 2, 3, 5, 14],14425: [0, 16, 3, 4, 6], 6: [0, 5, 7, 15, 16, 17, 18],14437: [0, 1, 6, 8, 13, 18], 8: [9, 18, 19, 13, 7],14449: [8, 10, 19, 20, 13], 10: [1, 9, 11, 13, 20, 21],144511: [1, 2, 10, 12, 14, 15, 21], 12: [11, 16, 3, 14, 15],144613: [8, 1, 10, 9, 7], 14: [11, 12, 2, 3, 4],144715: [6, 11, 12, 16, 17, 21, 22],144816: [3, 12, 5, 6, 15], 17: [18, 19, 22, 6, 15],144918: [8, 17, 19, 6, 7], 19: [8, 9, 17, 18, 20, 22],145020: [9, 10, 19, 21, 22], 21: [10, 11, 20, 22, 15],145122: [17, 19, 20, 21, 15]},1452name = "Kittell Graph")14531454_circle_embedding(g, range(3), shift=.75)1455_circle_embedding(g, range(3,13), radius = .4)1456_circle_embedding(g, range(15,22), radius = .2, shift=-.15)1457pos = g.get_pos()1458pos[13] = (-.65,-.35)1459pos[14] = (.65,-.35)1460pos[22] = (0,0)14611462return g14631464def CameronGraph():1465r"""1466Returns the Cameron graph.14671468The Cameron graph is strongly regular with parameters `v = 231, k = 30,1469\lambda = 9, \mu = 3`.14701471For more information on the Cameron graph, see1472`<http://www.win.tue.nl/~aeb/graphs/Cameron.html>`_.14731474EXAMPLES::14751476sage: g = graphs.CameronGraph()1477sage: g.order()14782311479sage: g.size()148034651481sage: g.is_strongly_regular(parameters = True) # long time1482(231, 30, 9, 3)14831484"""1485from sage.groups.perm_gps.permgroup_named import MathieuGroup1486from itertools import combinations1487g = Graph(name="Cameron Graph")1488sets = MathieuGroup(22).orbit((1,2,3,7,10,20), action = "OnSets")1489for s in sets:1490for a,b,c,d in combinations(set(s),4):1491g.add_edges([((a,b),(c,d)),((a,c),(b,d)), ((a,d),(b,c))])14921493g.relabel()1494ordering = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 18, 19, 20,149521, 24, 25, 26, 27, 29, 31, 34, 35, 38, 39, 96, 97, 101, 105,149651, 117, 198, 32, 196, 201, 131, 167, 199, 197, 86, 102, 195,1497200, 186, 144, 202, 177, 44, 53, 58, 45, 48, 54, 43, 57, 50,149846, 59, 133, 169, 104, 188, 118, 208, 157, 52, 207, 209, 132,1499204, 13, 187, 33, 203, 70, 145, 103, 168, 178, 87, 124, 123,1500125, 111, 120, 116, 119, 112, 95, 114, 115, 137, 218, 213, 108,150176, 77, 74, 62, 64, 67, 63, 68, 69, 61, 41, 75, 73, 66, 71, 72,150260, 22, 230, 151, 184, 138, 193, 109, 228, 174, 214, 219, 93,1503126, 143, 150, 146, 224, 181, 16, 223, 171, 90, 135, 106, 205,1504211, 121, 148, 160, 216, 222, 190, 36, 55, 185, 175, 94, 139,1505110, 215, 152, 220, 229, 194, 40, 128, 99, 141, 173, 154, 82,1506156, 164, 159, 28, 127, 158, 65, 162, 163, 153, 161, 155, 140,150798, 47, 113, 84, 180, 30, 129, 179, 183, 165, 176, 142, 100,150849, 134, 210, 170, 147, 91, 37, 206, 182, 191, 56, 136, 225,1509221, 149, 227, 217, 17, 107, 172, 212, 122, 226, 23, 85, 42,151080, 92, 81, 89, 78, 83, 88, 79, 130, 192, 189, 166]15111512_circle_embedding(g, ordering)1513return g15141515def ChvatalGraph():1516r"""1517Returns the Chvatal graph.15181519Chvatal graph is one of the few known graphs to satisfy Grunbaum's1520conjecture that for every m, n, there is an m-regular,1521m-chromatic graph of girth at least n. For more information, see this1522`Wikipedia article on the Chvatal graph <http://en.wikipedia.org/wiki/Chv%C3%A1tal_graph>`_.15231524EXAMPLES:15251526The Chvatal graph has 12 vertices and 24 edges. It is a 4-regular,15274-chromatic graph with radius 2, diameter 2, and girth 4. ::15281529sage: G = graphs.ChvatalGraph(); G1530Chvatal graph: Graph on 12 vertices1531sage: G.order(); G.size()1532121533241534sage: G.degree()1535[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]1536sage: G.chromatic_number()153741538sage: G.radius(); G.diameter(); G.girth()1539215402154141542"""1543import networkx1544pos_dict = {}1545for i in range(5, 10):1546x = float(cos((pi / 2) + ((2 * pi) / 5) * i))1547y = float(sin((pi / 2) + ((2 * pi) / 5) * i))1548pos_dict[i] = (x, y)1549for i in range(5):1550x = float(2 * (cos((pi / 2) + ((2 * pi) / 5) * (i - 5))))1551y = float(2 * (sin((pi / 2) + ((2 * pi) / 5) * (i - 5))))1552pos_dict[i] = (x, y)1553pos_dict[10] = (0.5, 0)1554pos_dict[11] = (-0.5, 0)15551556return Graph(networkx.chvatal_graph(), pos=pos_dict, name="Chvatal graph")15571558def ClebschGraph():1559r"""1560Return the Clebsch graph.15611562EXAMPLES::15631564sage: g = graphs.ClebschGraph()1565sage: g.automorphism_group().cardinality()156619201567sage: g.girth()156841569sage: g.chromatic_number()157041571sage: g.diameter()157221573sage: g.show(figsize=[10, 10]) # long time1574"""1575g = Graph(pos={})1576x = 01577for i in range(8):1578g.add_edge(x % 16, (x + 1) % 16)1579g.add_edge(x % 16, (x + 6) % 16)1580g.add_edge(x % 16, (x + 8) % 16)1581x += 11582g.add_edge(x % 16, (x + 3) % 16)1583g.add_edge(x % 16, (x + 2) % 16)1584g.add_edge(x % 16, (x + 8) % 16)1585x += 115861587_circle_embedding(g, range(16), shift=.5)1588g.name("Clebsch graph")15891590return g15911592def CoxeterGraph():1593r"""1594Return the Coxeter graph.15951596See the :wikipedia:`Wikipedia page on the Coxeter graph1597<Coxeter_graph>`.15981599EXAMPLES::16001601sage: g = graphs.CoxeterGraph()1602sage: g.automorphism_group().cardinality()16033361604sage: g.girth()160571606sage: g.chromatic_number()160731608sage: g.diameter()160941610sage: g.show(figsize=[10, 10]) # long time1611"""1612g = Graph({161327: [6, 22, 14],161424: [0, 7, 18],161525: [8, 15, 2],161626: [10, 16, 23],1617}, pos={})16181619g.add_cycle(range(24))1620g.add_edges([(5, 11), (9, 20), (12, 1), (13, 19), (17, 4), (3, 21)])16211622_circle_embedding(g, range(24))1623_circle_embedding(g, [24, 25, 26], radius=.5)1624g.get_pos()[27] = (0, 0)16251626g.name("Coxeter Graph")16271628return g16291630def DesarguesGraph():1631"""1632Returns the Desargues graph.16331634PLOTTING: The layout chosen is the same as on the cover of [1].16351636EXAMPLE::16371638sage: D = graphs.DesarguesGraph()1639sage: L = graphs.LCFGraph(20,[5,-5,9,-9],5)1640sage: D.is_isomorphic(L)1641True1642sage: D.show() # long time16431644REFERENCE:16451646- [1] Harary, F. Graph Theory. Reading, MA: Addison-Wesley,16471994.1648"""1649from sage.graphs.generators.families import GeneralizedPetersenGraph1650G = GeneralizedPetersenGraph(10,3)1651G.name("Desargues Graph")1652return G16531654def DurerGraph():1655r"""1656Returns the Dürer graph.16571658For more information, see this1659`Wikipedia article on the Dürer graph <http://en.wikipedia.org/wiki/D%C3%BCrer_graph>`_.16601661EXAMPLES:16621663The Dürer graph is named after Albrecht Dürer. It is a planar graph1664with 12 vertices and 18 edges. ::16651666sage: G = graphs.DurerGraph(); G1667Durer graph: Graph on 12 vertices1668sage: G.is_planar()1669True1670sage: G.order()1671121672sage: G.size()16731816741675The Dürer graph has chromatic number 3, diameter 4, and girth 3. ::16761677sage: G.chromatic_number()167831679sage: G.diameter()168041681sage: G.girth()1682316831684Its automorphism group is isomorphic to `D_6`. ::16851686sage: ag = G.automorphism_group()1687sage: ag.is_isomorphic(DihedralGroup(6))1688True1689"""1690edge_dict = {16910: [1,5,6],16921: [2,7],16932: [3,8],16943: [4,9],16954: [5,10],16965: [11],16976: [8,10],16987: [9,11],16998: [10],17009: [11]}1701pos_dict = {17020: [2, 0],17031: [1, 1.73205080756888],17042: [-1, 1.73205080756888],17053: [-2, 0],17064: [-1, -1.73205080756888],17075: [1, -1.73205080756888],17086: [1, 0],17097: [0.5, 0.866025403784439],17108: [-0.5, 0.866025403784439],17119: [-1, 0],171210: [-0.5, -0.866025403784439],171311: [0.5, -0.866025403784439]}1714return Graph(edge_dict, pos=pos_dict, name="Durer graph")17151716def DyckGraph():1717"""1718Returns the Dyck graph.17191720For more information, see the `MathWorld article on the Dyck graph1721<http://mathworld.wolfram.com/DyckGraph.html>`_ or the `Wikipedia1722article on the Dyck graph <http://en.wikipedia.org/wiki/Dyck_graph>`_.17231724EXAMPLES:17251726The Dyck graph was defined by Walther von Dyck in 1881. It has `32`1727vertices and `48` edges, and is a cubic graph (regular of degree `3`)::17281729sage: G = graphs.DyckGraph(); G1730Dyck graph: Graph on 32 vertices1731sage: G.order()1732321733sage: G.size()1734481735sage: G.is_regular()1736True1737sage: G.is_regular(3)1738True17391740It is non-planar and Hamiltonian, as well as bipartite (making it a1741bicubic graph)::17421743sage: G.is_planar()1744False1745sage: G.is_hamiltonian()1746True1747sage: G.is_bipartite()1748True17491750It has radius `5`, diameter `5`, and girth `6`::17511752sage: G.radius()175351754sage: G.diameter()175551756sage: G.girth()1757617581759Its chromatic number is `2` and its automorphism group is of order1760`192`::17611762sage: G.chromatic_number()176321764sage: G.automorphism_group().cardinality()176519217661767It is a non-integral graph as it has irrational eigenvalues::17681769sage: G.characteristic_polynomial().factor()1770(x - 3) * (x + 3) * (x - 1)^9 * (x + 1)^9 * (x^2 - 5)^617711772It is a toroidal graph, and its embedding on a torus is dual to an1773embedding of the Shrikhande graph (:meth:`ShrikhandeGraph1774<GraphGenerators.ShrikhandeGraph>`).1775"""1776pos_dict = {}1777for i in range(8):1778pos_dict[i] = [float(cos((2*i) * pi/8)),1779float(sin((2*i) * pi/8))]1780pos_dict[8 + i] = [0.75 * pos_dict[i][0],17810.75 * pos_dict[i][1]]1782pos_dict[16 + i] = [0.50 * pos_dict[i][0],17830.50 * pos_dict[i][1]]1784pos_dict[24 + i] = [0.25 * pos_dict[i][0],17850.25 * pos_dict[i][1]]17861787edge_dict = {17880O00: [0O07, 0O01, 0O10], 0O10: [0O00, 0O27, 0O21],17890O01: [0O00, 0O02, 0O11], 0O11: [0O01, 0O20, 0O22],17900O02: [0O01, 0O03, 0O12], 0O12: [0O02, 0O21, 0O23],17910O03: [0O02, 0O04, 0O13], 0O13: [0O03, 0O22, 0O24],17920O04: [0O03, 0O05, 0O14], 0O14: [0O04, 0O23, 0O25],17930O05: [0O04, 0O06, 0O15], 0O15: [0O05, 0O24, 0O26],17940O06: [0O05, 0O07, 0O16], 0O16: [0O06, 0O25, 0O27],17950O07: [0O06, 0O00, 0O17], 0O17: [0O07, 0O26, 0O20],179617970O20: [0O17, 0O11, 0O30], 0O30: [0O20, 0O35, 0O33],17980O21: [0O10, 0O12, 0O31], 0O31: [0O21, 0O36, 0O34],17990O22: [0O11, 0O13, 0O32], 0O32: [0O22, 0O37, 0O35],18000O23: [0O12, 0O14, 0O33], 0O33: [0O23, 0O30, 0O36],18010O24: [0O13, 0O15, 0O34], 0O34: [0O24, 0O31, 0O37],18020O25: [0O14, 0O16, 0O35], 0O35: [0O25, 0O32, 0O30],18030O26: [0O15, 0O17, 0O36], 0O36: [0O26, 0O33, 0O31],18040O27: [0O16, 0O10, 0O37], 0O37: [0O27, 0O34, 0O32],1805}18061807return Graph(edge_dict, pos=pos_dict, name="Dyck graph")18081809def HortonGraph():1810r"""1811Returns the Horton Graph.18121813The Horton graph is a cubic 3-connected non-hamiltonian graph. For more1814information, see the :wikipedia:`Horton_graph`.18151816EXAMPLES::18171818sage: g = graphs.HortonGraph()1819sage: g.order()1820961821sage: g.size()18221441823sage: g.radius()1824101825sage: g.diameter()1826101827sage: g.girth()182861829sage: g.automorphism_group().cardinality()1830961831sage: g.chromatic_number()183221833sage: g.is_hamiltonian() # not tested -- veeeery long1834False1835"""1836g = Graph(name = "Horton Graph")18371838# Each group of the 6 groups of vertices is based on the same 3-regular1839# graph.1840from sage.graphs.generators.families import LCFGraph1841lcf = LCFGraph(16,[5,-5],8)1842lcf.delete_edge(15,0)1843lcf.delete_edge(7,8)18441845for i in range(6):1846for u,v in lcf.edges(labels=False):1847g.add_edge((i,u),(i,v))18481849# Modifying the groups and linking them together1850for i in range(3):1851g.add_edge((2*i,0),(2*i+1,7))1852g.add_edge((2*i+1,8),(2*i,7))1853g.add_edge((2*i,15),(2*i+1,0))1854g.add_edge((2*i,8),1)1855g.add_edge((2*i+1,14),2)1856g.add_edge((2*i+1,10),0)18571858# Embedding1859for i in range(6):1860_circle_embedding(g, [(i,j) for j in range(16)], center=(cos(2*i*pi/6),sin(2*i*pi/6)), radius=.3)18611862for i in range(3):1863g.delete_vertex((2*i+1,15))18641865_circle_embedding(g, range(3), radius=.2, shift=-0.75)18661867g.relabel()18681869return g18701871def EllinghamHorton54Graph():1872r"""1873Returns the Ellingham-Horton 54-graph.18741875For more information, see the :wikipedia:`Wikipedia page on the1876Ellingham-Horton graphs <Ellingham-Horton_graph>`18771878EXAMPLE:18791880This graph is 3-regular::18811882sage: g = graphs.EllinghamHorton54Graph()1883sage: g.is_regular(k=3)1884True18851886It is 3-connected and bipartite::18871888sage: g.vertex_connectivity() # not tested - too long188931890sage: g.is_bipartite()1891True18921893It is not Hamiltonian::18941895sage: g.is_hamiltonian() # not tested - too long1896False18971898... and it has a nice drawing ::18991900sage: g.show(figsize=[10, 10]) # not tested - too long19011902TESTS::19031904sage: g.show() # long time1905"""1906from sage.graphs.generators.basic import CycleGraph1907up = CycleGraph(16)1908low = 2*CycleGraph(6)19091910for v in range(6):1911low.add_edge(v, v + 12)1912low.add_edge(v + 6, v + 12)1913low.add_edge(12, 15)1914low.delete_edge(1, 2)1915low.delete_edge(8, 7)1916low.add_edge(1, 8)1917low.add_edge(7, 2)191819191920# The set of vertices on top is 0..151921# Bottom left is 16..331922# Bottom right is 34..521923# The two other vertices are 53, 541924g = up + 2*low1925g.name("Ellingham-Horton 54-graph")1926g.set_pos({})19271928g.add_edges([(15, 4), (3, 8), (7, 12), (11, 0), (2, 13), (5, 10)])1929g.add_edges([(30, 6), (29, 9), (48, 14), (47, 1)])1930g.add_edge(32, 52)1931g.add_edge(50, 52)1932g.add_edge(33, 53)1933g.add_edge(51, 53)1934g.add_edge(52, 53)19351936# Top1937_circle_embedding(g, range(16), center=(0, .5), shift=.5, radius=.5)19381939# Bottom-left1940_circle_embedding(g, range(16, 22), center=(-1.5, -1))1941_circle_embedding(g, range(22, 28), center=(-1.5, -1), radius=.5)1942_circle_embedding(g, range(28, 34), center=(-1.5, -1), radius=.7)19431944# Bottom right1945_circle_embedding(g, range(34, 40), center=(1.5, -1))1946_circle_embedding(g, range(40, 46), center=(1.5, -1), radius=.5)1947_circle_embedding(g, range(46, 52), center=(1.5, -1), radius=.7)19481949d = g.get_pos()1950d[52] = (-.3, -2.5)1951d[53] = (.3, -2.5)1952d[31] = (-2.2, -.9)1953d[28] = (-.8, -.9)1954d[46] = (2.2, -.9)1955d[49] = (.8, -.9)195619571958return g19591960def EllinghamHorton78Graph():1961r"""1962Returns the Ellingham-Horton 78-graph.19631964For more information, see the :wikipedia:`Wikipedia page on the1965Ellingham-Horton graphs1966<http://en.wikipedia.org/wiki/Ellingham%E2%80%93Horton_graph>`19671968EXAMPLE:19691970This graph is 3-regular::19711972sage: g = graphs.EllinghamHorton78Graph()1973sage: g.is_regular(k=3)1974True19751976It is 3-connected and bipartite::19771978sage: g.vertex_connectivity() # not tested - too long197931980sage: g.is_bipartite()1981True19821983It is not Hamiltonian::19841985sage: g.is_hamiltonian() # not tested - too long1986False19871988... and it has a nice drawing ::19891990sage: g.show(figsize=[10,10]) # not tested - too long19911992TESTS::19931994sage: g.show(figsize=[10, 10]) # not tested - too long1995"""1996g = Graph({19970: [1, 5, 60], 1: [2, 12], 2: [3, 7], 3: [4, 14], 4: [5, 9],19985: [6], 6: [7, 11], 7: [15], 8: [9, 13, 22], 9: [10],199910: [11, 72], 11: [12], 12: [13], 13: [14], 14: [72],200015: [16, 20], 16: [17, 27], 17: [18, 22], 18: [19, 29],200119: [20, 24], 20: [21], 21: [22, 26], 23: [24, 28, 72],200224: [25], 25: [26, 71], 26: [27], 27: [28], 28: [29],200329: [69], 30: [31, 35, 52], 31: [32, 42], 32: [33, 37],200433: [34, 43], 34: [35, 39], 35: [36], 36: [41, 63],200537: [65, 66], 38: [39, 59, 74], 39: [40], 40: [41, 44],200641: [42], 42: [74], 43: [44, 74], 44: [45], 45: [46, 50],200746: [47, 57], 47: [48, 52], 48: [49, 75], 49: [50, 54],200850: [51], 51: [52, 56], 53: [54, 58, 73], 54: [55],200955: [56, 59], 56: [57], 57: [58], 58: [75], 59: [75],201060: [61, 64], 61: [62, 71], 62: [63, 77], 63: [67],201164: [65, 69], 65: [77], 66: [70, 73], 67: [68, 73],201268: [69, 76], 70: [71, 76], 76: [77]}, pos={})20132014_circle_embedding(g, range(15), center=(-2.5, 1.5))2015_circle_embedding(g, range(15, 30), center=(-2.5, -1.5))2016_circle_embedding(g, [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,201742, 74, 43, 44], center=(2.5, 1.5))2018_circle_embedding(g, [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,201957, 58, 75, 59], center=(2.5, -1.5))20202021d = g.get_pos()20222023d[76] = (-.2, -.1)2024d[77] = (.2, .1)2025d[38] = (2.2, .1)2026d[52] = (2.3, -.1)2027d[15] = (-2.1, -.1)2028d[72] = (-2.1, .1)20292030_line_embedding(g, [60, 61, 62, 63], first=(-1, 2), last=(1, 2))2031_line_embedding(g, [64, 65, 37], first=(-.5, 1.5), last=(1.2, 1.5))2032_line_embedding(g, [66, 73, 67, 68, 69], first=(1.2, -2),2033last=(-.8, -2))2034_line_embedding(g, [66, 70, 71], first=(.7, -1.5), last=(-1, -1.5))20352036g.name("Ellingham-Horton 78-graph")20372038return g20392040def ErreraGraph():2041r"""2042Returns the Errera graph.20432044For more information, see this2045`Wikipedia article on the Errera graph <http://en.wikipedia.org/wiki/Errera_graph>`_.20462047EXAMPLES:20482049The Errera graph is named after Alfred Errera. It is a planar graph2050on 17 vertices and having 45 edges. ::20512052sage: G = graphs.ErreraGraph(); G2053Errera graph: Graph on 17 vertices2054sage: G.is_planar()2055True2056sage: G.order()2057172058sage: G.size()20594520602061The Errera graph is Hamiltonian with radius 3, diameter 4, girth 3,2062and chromatic number 4. ::20632064sage: G.is_hamiltonian()2065True2066sage: G.radius()206732068sage: G.diameter()206942070sage: G.girth()207132072sage: G.chromatic_number()2073420742075Each vertex degree is either 5 or 6. That is, if `f` counts the2076number of vertices of degree 5 and `s` counts the number of vertices2077of degree 6, then `f + s` is equal to the order of the Errera2078graph. ::20792080sage: D = G.degree_sequence()2081sage: D.count(5) + D.count(6) == G.order()2082True20832084The automorphism group of the Errera graph is isomorphic to the2085dihedral group of order 20. ::20862087sage: ag = G.automorphism_group()2088sage: ag.is_isomorphic(DihedralGroup(10))2089True2090"""2091edge_dict = {20920: [1,7,14,15,16],20931: [2,9,14,15],20942: [3,8,9,10,14],20953: [4,9,10,11],20964: [5,10,11,12],20975: [6,11,12,13],20986: [7,8,12,13,16],20997: [13,15,16],21008: [10,12,14,16],21019: [11,13,15],210210: [12],210311: [13],210413: [15],210514: [16]}2106return Graph(edge_dict, name="Errera graph")21072108def FlowerSnark():2109"""2110Returns a Flower Snark.21112112A flower snark has 20 vertices. It is part of the class of2113biconnected cubic graphs with edge chromatic number = 4, known as2114snarks. (i.e.: the Petersen graph). All snarks are not Hamiltonian,2115non-planar and have Petersen graph graph minors.21162117PLOTTING: Upon construction, the position dictionary is filled to2118override the spring-layout algorithm. By convention, the nodes are2119drawn 0-14 on the outer circle, and 15-19 in an inner pentagon.21202121REFERENCES:21222123- [1] Weisstein, E. (1999). "Flower Snark - from Wolfram2124MathWorld". [Online] Available:2125http://mathworld.wolfram.com/FlowerSnark.html [2007, February 17]21262127EXAMPLES: Inspect a flower snark::21282129sage: F = graphs.FlowerSnark()2130sage: F2131Flower Snark: Graph on 20 vertices2132sage: F.graph6_string()2133'ShCGHC@?GGg@?@?Gp?K??C?CA?G?_G?Cc'21342135Now show it::21362137sage: F.show() # long time2138"""2139pos_dict = {}2140for i in range(15):2141x = float(2.5*(cos((pi/2) + ((2*pi)/15)*i)))2142y = float(2.5*(sin((pi/2) + ((2*pi)/15)*i)))2143pos_dict[i] = (x,y)2144for i in range(15,20):2145x = float(cos((pi/2) + ((2*pi)/5)*i))2146y = float(sin((pi/2) + ((2*pi)/5)*i))2147pos_dict[i] = (x,y)2148return Graph({0:[1,14,15],1:[2,11],2:[3,7],3:[2,4,16],4:[5,14], \21495:[6,10],6:[5,7,17],8:[7,9,13],9:[10,18],11:[10,12], \215012:[13,19],13:[14],15:[19],16:[15,17],18:[17,19]}, \2151pos=pos_dict, name="Flower Snark")215221532154def FolkmanGraph():2155"""2156Returns the Folkman graph.21572158See the :wikipedia:`Wikipedia page on the Folkman Graph2159<Folkman_graph>`.21602161EXAMPLE::21622163sage: g = graphs.FolkmanGraph()2164sage: g.order()2165202166sage: g.size()2167402168sage: g.diameter()216942170sage: g.girth()217142172sage: g.charpoly().factor()2173(x - 4) * (x + 4) * x^10 * (x^2 - 6)^42174sage: g.chromatic_number()217522176sage: g.is_eulerian()2177True2178sage: g.is_hamiltonian()2179True2180sage: g.is_vertex_transitive()2181False2182sage: g.is_bipartite()2183True2184"""2185from sage.graphs.generators.families import LCFGraph2186g= LCFGraph(20, [5, -7, -7, 5], 5)2187g.name("Folkman Graph")2188return g218921902191def FosterGraph():2192"""2193Returns the Foster graph.21942195See the :wikipedia:`Wikipedia page on the Foster Graph2196<Foster_graph>`.21972198EXAMPLE::21992200sage: g = graphs.FosterGraph()2201sage: g.order()2202902203sage: g.size()22041352205sage: g.diameter()220682207sage: g.girth()2208102209sage: g.automorphism_group().cardinality()221043202211sage: g.is_hamiltonian()2212True2213"""2214from sage.graphs.generators.families import LCFGraph2215g= LCFGraph(90, [17, -9, 37, -37, 9, -17], 15)2216g.name("Foster Graph")2217return g221822192220def FranklinGraph():2221r"""2222Returns the Franklin graph.22232224For more information, see this2225`Wikipedia article on the Franklin graph <http://en.wikipedia.org/wiki/Franklin_graph>`_.22262227EXAMPLES:22282229The Franklin graph is named after Philip Franklin. It is a22303-regular graph on 12 vertices and having 18 edges. ::22312232sage: G = graphs.FranklinGraph(); G2233Franklin graph: Graph on 12 vertices2234sage: G.is_regular(3)2235True2236sage: G.order()2237122238sage: G.size()22391822402241The Franklin graph is a Hamiltonian, bipartite graph with radius 3,2242diameter 3, and girth 4. ::22432244sage: G.is_hamiltonian()2245True2246sage: G.is_bipartite()2247True2248sage: G.radius()224932250sage: G.diameter()225132252sage: G.girth()2253422542255It is a perfect, triangle-free graph having chromatic number 2. ::22562257sage: G.is_perfect()2258True2259sage: G.is_triangle_free()2260True2261sage: G.chromatic_number()226222263"""2264edge_dict = {22650: [1,5,6],22661: [2,7],22672: [3,8],22683: [4,9],22694: [5,10],22705: [11],22716: [7,9],22727: [10],22738: [9,11],227410: [11]}2275pos_dict = {22760: [2, 0],22771: [1, 1.73205080756888],22782: [-1, 1.73205080756888],22793: [-2, 0],22804: [-1, -1.73205080756888],22815: [1, -1.73205080756888],22826: [1, 0],22837: [0.5, 0.866025403784439],22848: [-0.5, 0.866025403784439],22859: [-1, 0],228610: [-0.5, -0.866025403784439],228711: [0.5, -0.866025403784439]}2288return Graph(edge_dict, pos=pos_dict, name="Franklin graph")22892290def FruchtGraph():2291"""2292Returns a Frucht Graph.22932294A Frucht graph has 12 nodes and 18 edges. It is the smallest cubic2295identity graph. It is planar and it is Hamiltonian.22962297This constructor is dependent on NetworkX's numeric labeling.22982299PLOTTING: Upon construction, the position dictionary is filled to2300override the spring-layout algorithm. By convention, the first2301seven nodes are on the outer circle, with the next four on an inner2302circle and the last in the center.23032304REFERENCES:23052306- [1] Weisstein, E. (1999). "Frucht Graph - from Wolfram2307MathWorld". [Online] Available:2308http://mathworld.wolfram.com/FruchtGraph.html [2007, February 17]23092310EXAMPLES::23112312sage: FRUCHT = graphs.FruchtGraph()2313sage: FRUCHT2314Frucht graph: Graph on 12 vertices2315sage: FRUCHT.graph6_string()2316'KhCKM?_EGK?L'2317sage: (graphs.FruchtGraph()).show() # long time2318"""2319pos_dict = {}2320for i in range(7):2321x = float(2*(cos((pi/2) + ((2*pi)/7)*i)))2322y = float(2*(sin((pi/2) + ((2*pi)/7)*i)))2323pos_dict[i] = (x,y)2324pos_dict[7] = (0,1)2325pos_dict[8] = (-1,0)2326pos_dict[9] = (0,-1)2327pos_dict[10] = (1,0)2328pos_dict[11] = (0,0)2329import networkx2330G = networkx.frucht_graph()2331return Graph(G, pos=pos_dict, name="Frucht graph")23322333def GoldnerHararyGraph():2334r"""2335Return the Goldner-Harary graph.23362337For more information, see this2338`Wikipedia article on the Goldner-Harary graph <http://en.wikipedia.org/wiki/Goldner%E2%80%93Harary_graph>`_.23392340EXAMPLES:23412342The Goldner-Harary graph is named after A. Goldner and Frank Harary.2343It is a planar graph having 11 vertices and 27 edges. ::23442345sage: G = graphs.GoldnerHararyGraph(); G2346Goldner-Harary graph: Graph on 11 vertices2347sage: G.is_planar()2348True2349sage: G.order()2350112351sage: G.size()23522723532354The Goldner-Harary graph is chordal with radius 2, diameter 2, and2355girth 3. ::23562357sage: G.is_chordal()2358True2359sage: G.radius()236022361sage: G.diameter()236222363sage: G.girth()2364323652366Its chromatic number is 4 and its automorphism group is isomorphic to2367the dihedral group `D_6`. ::23682369sage: G.chromatic_number()237042371sage: ag = G.automorphism_group()2372sage: ag.is_isomorphic(DihedralGroup(6))2373True2374"""2375edge_dict = {23760: [1,3,4],23771: [2,3,4,5,6,7,10],23782: [3,7],23793: [7,8,9,10],23804: [3,5,9,10],23815: [10],23826: [7,10],23837: [8,10],23848: [10],23859: [10]}23862387pos = {23880: (-2, 0),23891: (0, 1.5),23902: (2, 0),23913: (0, -1.5),23924: (-1.5, 0),23935: (-0.5, 0.5),23946: (0.5, 0.5),23957: (1.5, 0),23968: (0.5, -0.5),23979: (-0.5, -0.5),239810: (0, 0)}23992400return Graph(edge_dict, pos = pos, name="Goldner-Harary graph")24012402def GrayGraph(embedding=1):2403r"""2404Returns the Gray graph.24052406See the :wikipedia:`Wikipedia page on the Gray Graph2407<Gray_graph>`.24082409INPUT:24102411- ``embedding`` -- two embeddings are available, and can be2412selected by setting ``embedding`` to 1 or 2.24132414EXAMPLES::24152416sage: g = graphs.GrayGraph()2417sage: g.order()2418542419sage: g.size()2420812421sage: g.girth()242282423sage: g.diameter()242462425sage: g.show(figsize=[10, 10]) # long time2426sage: graphs.GrayGraph(embedding = 2).show(figsize=[10, 10]) # long time24272428TESTS::24292430sage: graphs.GrayGraph(embedding = 3)2431Traceback (most recent call last):2432...2433ValueError: The value of embedding must be 1, 2, or 3.2434"""24352436from sage.graphs.generators.families import LCFGraph2437g = LCFGraph(54, [-25,7,-7,13,-13,25], 9)2438g.name("Gray graph")24392440if embedding == 1:2441o = g.automorphism_group(orbits=True)[-1]2442_circle_embedding(g, o[0], center=(0, 0), radius=1)2443_circle_embedding(g, o[1], center=(0, 0), radius=.6, shift=-.5)24442445elif embedding != 2:2446raise ValueError("The value of embedding must be 1, 2, or 3.")24472448return g24492450def GrotzschGraph():2451r"""2452Returns the Grötzsch graph.24532454The Grötzsch graph is an example of a triangle-free graph with2455chromatic number equal to 4. For more information, see this2456`Wikipedia article on Grötzsch graph <http://en.wikipedia.org/wiki/Gr%C3%B6tzsch_graph>`_.24572458REFERENCE:24592460- [1] Weisstein, Eric W. "Grotzsch Graph."2461From MathWorld--A Wolfram Web Resource.2462http://mathworld.wolfram.com/GroetzschGraph.html24632464EXAMPLES:24652466The Grötzsch graph is named after Herbert Grötzsch. It is a2467Hamiltonian graph with 11 vertices and 20 edges. ::24682469sage: G = graphs.GrotzschGraph(); G2470Grotzsch graph: Graph on 11 vertices2471sage: G.is_hamiltonian()2472True2473sage: G.order()2474112475sage: G.size()24762024772478The Grötzsch graph is triangle-free and having radius 2, diameter 2,2479and girth 4. ::24802481sage: G.is_triangle_free()2482True2483sage: G.radius()248422485sage: G.diameter()248622487sage: G.girth()2488424892490Its chromatic number is 4 and its automorphism group is isomorphic2491to the dihedral group `D_5`. ::24922493sage: G.chromatic_number()249442495sage: ag = G.automorphism_group()2496sage: ag.is_isomorphic(DihedralGroup(5))2497True2498"""2499g = Graph()2500g.add_vertices(range(11))25012502edges = [];2503for u in range(1,6):2504edges.append( (0,u) )25052506edges.append( (10,6) )25072508for u in range(6,10):2509edges.append( (u,u+1) )2510edges.append( (u,u-4) )25112512edges.append( (10,1) )25132514for u in range(7,11):2515edges.append( (u,u-6) )25162517edges.append((6,5))25182519g.add_edges(edges)25202521pos = {}2522pos[0] = (0,0)2523for u in range(1,6):2524theta = (u-1)*2*pi/52525pos[u] = (float(5*sin(theta)),float(5*cos(theta)))2526pos[u+5] = (2*pos[u][0], 2*pos[u][1])25272528g.set_pos(pos)2529g.name("Grotzsch graph")2530return g25312532def HeawoodGraph():2533"""2534Returns a Heawood graph.25352536The Heawood graph is a cage graph that has 14 nodes. It is a cubic2537symmetric graph. (See also the Moebius-Kantor graph). It is2538nonplanar and Hamiltonian. It has diameter = 3, radius = 3, girth =25396, chromatic number = 2. It is 4-transitive but not 5-transitive.25402541This constructor is dependent on NetworkX's numeric labeling.25422543PLOTTING: Upon construction, the position dictionary is filled to2544override the spring-layout algorithm. By convention, the nodes are2545positioned in a circular layout with the first node appearing at2546the top, and then continuing counterclockwise.25472548REFERENCES:25492550- [1] Weisstein, E. (1999). "Heawood Graph - from Wolfram2551MathWorld". [Online] Available:2552http://mathworld.wolfram.com/HeawoodGraph.html [2007, February 17]25532554EXAMPLES::25552556sage: H = graphs.HeawoodGraph()2557sage: H2558Heawood graph: Graph on 14 vertices2559sage: H.graph6_string()2560'MhEGHC@AI?_PC@_G_'2561sage: (graphs.HeawoodGraph()).show() # long time2562"""2563pos_dict = {}2564for i in range(14):2565x = float(cos((pi/2) + (pi/7)*i))2566y = float(sin((pi/2) + (pi/7)*i))2567pos_dict[i] = (x,y)2568import networkx2569G = networkx.heawood_graph()2570return Graph(G, pos=pos_dict, name="Heawood graph")25712572def HerschelGraph():2573r"""2574Returns the Herschel graph.25752576For more information, see this2577`Wikipedia article on the Herschel graph <http://en.wikipedia.org/wiki/Herschel_graph>`_.25782579EXAMPLES:25802581The Herschel graph is named after Alexander Stewart Herschel. It is2582a planar, bipartite graph with 11 vertices and 18 edges. ::25832584sage: G = graphs.HerschelGraph(); G2585Herschel graph: Graph on 11 vertices2586sage: G.is_planar()2587True2588sage: G.is_bipartite()2589True2590sage: G.order()2591112592sage: G.size()25931825942595The Herschel graph is a perfect graph with radius 3, diameter 4, and2596girth 4. ::25972598sage: G.is_perfect()2599True2600sage: G.radius()260132602sage: G.diameter()260342604sage: G.girth()2605426062607Its chromatic number is 2 and its automorphism group is2608isomorphic to the dihedral group `D_6`. ::26092610sage: G.chromatic_number()261122612sage: ag = G.automorphism_group()2613sage: ag.is_isomorphic(DihedralGroup(6))2614True2615"""2616edge_dict = {26170: [1,3,4],26181: [2,5,6],26192: [3,7],26203: [8,9],26214: [5,9],26225: [10],26236: [7,10],26247: [8],26258: [10],26269: [10]}2627pos_dict = {26280: [2, 0],26291: [0, 2],26302: [-2, 0],26313: [0, -2],26324: [1, 0],26335: [0.5, 0.866025403784439],26346: [-0.5, 0.866025403784439],26357: [-1, 0],26368: [-0.5, -0.866025403784439],26379: [0.5, -0.866025403784439],263810: [0, 0]}2639return Graph(edge_dict, pos=pos_dict, name="Herschel graph")26402641def HigmanSimsGraph(relabel=True):2642r"""2643The Higman-Sims graph is a remarkable strongly regular2644graph of degree 22 on 100 vertices. For example, it can2645be split into two sets of 50 vertices each, so that each2646half induces a subgraph isomorphic to the2647Hoffman-Singleton graph2648(:meth:`~HoffmanSingletonGraph`).2649This can be done in 352 ways (see [BROUWER-HS-2009]_).26502651Its most famous property is that the automorphism2652group has an index 2 subgroup which is one of the265326 sporadic groups. [HIGMAN1968]_26542655The construction used here follows [HAFNER2004]_.26562657INPUT:26582659- ``relabel`` - default: ``True``. If ``True`` the2660vertices will be labeled with consecutive integers.2661If ``False`` the labels are strings that are three2662digits long. "xyz" means the vertex is in group2663x (zero through three), pentagon or pentagram y2664(zero through four), and is vertex z (zero2665through four) of that pentagon or pentagram.2666See [HAFNER2004]_ for more.26672668OUTPUT:26692670The Higman-Sims graph.26712672EXAMPLES:26732674A split into the first 50 and last 50 vertices2675will induce two copies of the Hoffman-Singleton graph,2676and we illustrate another such split, which is obvious2677based on the construction used. ::26782679sage: H = graphs.HigmanSimsGraph()2680sage: A = H.subgraph(range(0,50))2681sage: B = H.subgraph(range(50,100))2682sage: K = graphs.HoffmanSingletonGraph()2683sage: K.is_isomorphic(A) and K.is_isomorphic(B)2684True2685sage: C = H.subgraph(range(25,75))2686sage: D = H.subgraph(range(0,25)+range(75,100))2687sage: K.is_isomorphic(C) and K.is_isomorphic(D)2688True26892690The automorphism group contains only one nontrivial2691proper normal subgroup, which is of index 2 and is2692simple. It is known as the Higman-Sims group. ::26932694sage: H = graphs.HigmanSimsGraph()2695sage: G = H.automorphism_group()2696sage: g=G.order(); g2697887040002698sage: K = G.normal_subgroups()[1]2699sage: K.is_simple()2700True2701sage: g//K.order()2702227032704REFERENCES:27052706.. [BROUWER-HS-2009] `Higman-Sims graph2707<http://www.win.tue.nl/~aeb/graphs/Higman-Sims.html>`_.2708Andries E. Brouwer, accessed 24 October 2009.2709.. [HIGMAN1968] A simple group of order 44,352,000,2710Math.Z. 105 (1968) 110-113. D.G. Higman & C. Sims.2711.. [HAFNER2004] `On the graphs of Hoffman-Singleton and2712Higman-Sims2713<http://www.combinatorics.org/Volume_11/PDF/v11i1r77.pdf>`_.2714The Electronic Journal of Combinatorics 11 (2004), #R77,2715Paul R. Hafner, accessed 24 October 2009.27162717AUTHOR:27182719- Rob Beezer (2009-10-24)2720"""2721HS = Graph()2722HS.name('Higman-Sims graph')27232724# Four groups of either five pentagons, or five pentagrams2725# 4 x 5 x 5 = 100 vertices2726# First digit is "group", second is "penta{gon|gram}", third is "vertex"2727vlist = ['%d%d%d'%(g,p,v)2728for g in range(4) for p in range(5) for v in range(5)]2729for avertex in vlist:2730HS.add_vertex(avertex)27312732# Edges: Within groups 0 and 2, joined as pentagons2733# Edges: Within groups 1 and 3, joined as pentagrams2734for g in range(4):2735shift = 12736if g in [1,3]:2737shift += 12738for p in range(5):2739for v in range(5):2740HS.add_edge(('%d%d%d'%(g,p,v), '%d%d%d'%(g,p,(v+shift)%5)))27412742# Edges: group 0 to group 12743for x in range(5):2744for m in range(5):2745for c in range(5):2746y = (m*x+c)%52747HS.add_edge(('0%d%d'%(x,y), '1%d%d'%(m,c)))27482749# Edges: group 1 to group 22750for m in range(5):2751for A in range(5):2752for B in range(5):2753c = (2*(m-A)*(m-A)+B)%52754HS.add_edge(('1%d%d'%(m,c), '2%d%d'%(A,B)))27552756# Edges: group 2 to group 32757for A in range(5):2758for a in range(5):2759for b in range(5):2760B = (2*A*A+3*a*A-a*a+b)%52761HS.add_edge(('2%d%d'%(A,B), '3%d%d'%(a,b)))27622763# Edges: group 3 to group 02764for a in range(5):2765for b in range(5):2766for x in range(5):2767y = ((x-a)*(x-a)+b)%52768HS.add_edge(('3%d%d'%(a,b), '0%d%d'%(x,y)))27692770# Edges: group 0 to group 22771for x in range(5):2772for A in range(5):2773for B in range(5):2774y = (3*x*x+A*x+B+1)%52775HS.add_edge(('0%d%d'%(x,y), '2%d%d'%(A,B)))2776y = (3*x*x+A*x+B-1)%52777HS.add_edge(('0%d%d'%(x,y), '2%d%d'%(A,B)))27782779# Edges: group 1 to group 32780for m in range(5):2781for a in range(5):2782for b in range(5):2783c = (m*(m-a)+b+2)%52784HS.add_edge(('1%d%d'%(m,c), '3%d%d'%(a,b)))2785c = (m*(m-a)+b-2)%52786HS.add_edge(('1%d%d'%(m,c), '3%d%d'%(a,b)))27872788# Rename to integer vertex labels, creating dictionary2789# Or not, and create identity mapping2790if relabel:2791vmap = HS.relabel(return_map=True)2792else:2793vmap={}2794for v in vlist:2795vmap[v] = v2796# Layout vertices in a circle2797# In the order given in vlist2798# Using labels from vmap2799pos_dict = {}2800for i in range(100):2801x = float(cos((pi/2) + ((2*pi)/100)*i))2802y = float(sin((pi/2) + ((2*pi)/100)*i))2803pos_dict[vmap[vlist[i]]] = (x,y)2804HS.set_pos(pos_dict)2805return HS28062807def HoffmanSingletonGraph():2808r"""2809Returns the Hoffman-Singleton graph.28102811The Hoffman-Singleton graph is the Moore graph of degree 7,2812diameter 2 and girth 5. The Hoffman-Singleton theorem states that2813any Moore graph with girth 5 must have degree 2, 3, 7 or 57. The2814first three respectively are the pentagon, the Petersen graph, and2815the Hoffman-Singleton graph. The existence of a Moore graph with2816girth 5 and degree 57 is still open.28172818A Moore graph is a graph with diameter `d` and girth2819`2d + 1`. This implies that the graph is regular, and2820distance regular.28212822PLOTTING: Upon construction, the position dictionary is filled to2823override the spring-layout algorithm. A novel algorithm written by2824Tom Boothby gives a random layout which is pleasing to the eye.28252826REFERENCES:28272828.. [GodsilRoyle] Godsil, C. and Royle, G. Algebraic Graph Theory.2829Springer, 2001.28302831EXAMPLES::28322833sage: HS = graphs.HoffmanSingletonGraph()2834sage: Set(HS.degree())2835{7}2836sage: HS.girth()283752838sage: HS.diameter()283922840sage: HS.num_verts()28415028422843Note that you get a different layout each time you create the graph.2844::28452846sage: HS.layout()[1]2847(-0.844..., 0.535...)2848sage: graphs.HoffmanSingletonGraph().layout()[1]2849(-0.904..., 0.425...)28502851"""2852H = Graph({ \2853'q00':['q01'], 'q01':['q02'], 'q02':['q03'], 'q03':['q04'], 'q04':['q00'], \2854'q10':['q11'], 'q11':['q12'], 'q12':['q13'], 'q13':['q14'], 'q14':['q10'], \2855'q20':['q21'], 'q21':['q22'], 'q22':['q23'], 'q23':['q24'], 'q24':['q20'], \2856'q30':['q31'], 'q31':['q32'], 'q32':['q33'], 'q33':['q34'], 'q34':['q30'], \2857'q40':['q41'], 'q41':['q42'], 'q42':['q43'], 'q43':['q44'], 'q44':['q40'], \2858'p00':['p02'], 'p02':['p04'], 'p04':['p01'], 'p01':['p03'], 'p03':['p00'], \2859'p10':['p12'], 'p12':['p14'], 'p14':['p11'], 'p11':['p13'], 'p13':['p10'], \2860'p20':['p22'], 'p22':['p24'], 'p24':['p21'], 'p21':['p23'], 'p23':['p20'], \2861'p30':['p32'], 'p32':['p34'], 'p34':['p31'], 'p31':['p33'], 'p33':['p30'], \2862'p40':['p42'], 'p42':['p44'], 'p44':['p41'], 'p41':['p43'], 'p43':['p40']})2863for j in range(5):2864for i in range(5):2865for k in range(5):2866con = (i+j*k)%52867H.add_edge(('q%d%d'%(k,con),'p%d%d'%(j,i)))2868H.name('Hoffman-Singleton graph')2869from sage.combinat.permutation import Permutations2870from sage.misc.prandom import randint2871P = Permutations([1,2,3,4])2872qpp = [0] + list(P[randint(0,23)])2873ppp = [0] + list(P[randint(0,23)])2874qcycle = lambda i,s : ['q%s%s'%(i,(j+s)%5) for j in qpp]2875pcycle = lambda i,s : ['p%s%s'%(i,(j+s)%5) for j in ppp]2876l = 02877s = 02878D = []2879while l < 5:2880for q in qcycle(l,s):2881D.append(q)2882vv = 'p%s'%q[1]2883s = int([v[-1] for v in H.neighbors(q) if v[:2] == vv][0])2884for p in pcycle(l,s):2885D.append(p)2886vv = 'q%s'%(int(p[1])+1)2887v = [v[-1] for v in H.neighbors(p) if v[:2] == vv]2888if len(v):2889s = int(v[0])2890l+=12891map = H.relabel(return_map=True)2892pos_dict = {}2893for i in range(50):2894x = float(cos((pi/2) + ((2*pi)/50)*i))2895y = float(sin((pi/2) + ((2*pi)/50)*i))2896pos_dict[map[D[i]]] = (x,y)2897H.set_pos(pos_dict)2898return H28992900def HoffmanGraph():2901r"""2902Returns the Hoffman Graph.29032904See the :wikipedia:`Wikipedia page on the Hoffman graph2905<Hoffman_graph>`.29062907EXAMPLES::29082909sage: g = graphs.HoffmanGraph()2910sage: g.is_bipartite()2911True2912sage: g.is_hamiltonian() # long time2913True2914sage: g.radius()291532916sage: g.diameter()291742918sage: g.automorphism_group().cardinality()2919482920"""2921g = Graph({29220: [1, 7, 8, 13],29231: [2, 9, 14],29242: [3, 8, 10],29253: [4, 9, 15],29264: [5, 10, 11],29275: [6, 12, 14],29286: [7, 11, 13],29297: [12, 15],29308: [12, 14],29319: [11, 13],293210: [12, 15],293311: [14],293413: [15]})2935g.set_pos({})2936_circle_embedding(g, range(8))2937_circle_embedding(g, range(8, 14), radius=.7, shift=.5)2938_circle_embedding(g, [14, 15], radius=.1)29392940g.name("Hoffman Graph")29412942return g29432944def HoltGraph():2945r"""2946Returns the Holt graph (also called the Doyle graph)29472948See the :wikipedia:`Wikipedia page on the Holt graph2949<Holt_graph>`.29502951EXAMPLES::29522953sage: g = graphs.HoltGraph();g2954Holt graph: Graph on 27 vertices2955sage: g.is_regular()2956True2957sage: g.is_vertex_transitive()2958True2959sage: g.chromatic_number()296032961sage: g.is_hamiltonian() # long time2962True2963sage: g.radius()296432965sage: g.diameter()296632967sage: g.girth()296852969sage: g.automorphism_group().cardinality()2970542971"""2972g = Graph(loops=False, name = "Holt graph", pos={})2973for x in range(9):2974for y in range(3):2975g.add_edge((x,y),((4*x+1)%9,(y-1)%3))2976g.add_edge((x,y),((4*x-1)%9,(y-1)%3))2977g.add_edge((x,y),((7*x+7)%9,(y+1)%3))2978g.add_edge((x,y),((7*x-7)%9,(y+1)%3))29792980for j in range(0,6,2):2981_line_embedding(g, [(x,j/2) for x in range(9)],2982first=(cos(2*j*pi/6),sin(2*j*pi/6)),2983last=(cos(2*(j+1)*pi/6),sin(2*(j+1)*pi/6)))29842985return g29862987def KrackhardtKiteGraph():2988"""2989Returns a Krackhardt kite graph with 10 nodes.29902991The Krackhardt kite graph was originally developed by David2992Krackhardt for the purpose of studying social networks. It is used2993to show the distinction between: degree centrality, betweeness2994centrality, and closeness centrality. For more information read the2995plotting section below in conjunction with the example.29962997REFERENCES:29982999- [1] Kreps, V. (2002). "Social Network Analysis". [Online] Available:3000http://www.orgnet.com/sna.html30013002This constructor depends on NetworkX numeric labeling.30033004PLOTTING: Upon construction, the position dictionary is filled to3005override the spring-layout algorithm. By convention, the graph is3006drawn left to right, in top to bottom row sequence of [2, 3, 2, 1,30071, 1] nodes on each row. This places the fourth node (3) in the3008center of the kite, with the highest degree. But the fourth node3009only connects nodes that are otherwise connected, or those in its3010clique (i.e.: Degree Centrality). The eighth (7) node is where the3011kite meets the tail. It has degree = 3, less than the average, but3012is the only connection between the kite and tail (i.e.: Betweenness3013Centrality). The sixth and seventh nodes (5 and 6) are drawn in the3014third row and have degree = 5. These nodes have the shortest path3015to all other nodes in the graph (i.e.: Closeness Centrality).3016Please execute the example for visualization.30173018EXAMPLE: Construct and show a Krackhardt kite graph30193020::30213022sage: g = graphs.KrackhardtKiteGraph()3023sage: g.show() # long time3024"""3025pos_dict = {0:(-1,4),1:(1,4),2:(-2,3),3:(0,3),4:(2,3),5:(-1,2),6:(1,2),7:(0,1),8:(0,0),9:(0,-1)}3026import networkx3027G = networkx.krackhardt_kite_graph()3028return Graph(G, pos=pos_dict, name="Krackhardt Kite Graph")30293030def LjubljanaGraph(embedding=1):3031r"""3032Returns the Ljubljana Graph.30333034The Ljubljana graph is a bipartite 3-regular graph on 1123035vertices and 168 edges. It is not vertex-transitive as it has3036two orbits which are also independent sets of size 56. See the3037:wikipedia:`Wikipedia page on the Ljubljana Graph3038<Ljubljana_graph>`.30393040The default embedding is obtained from the Heawood graph.30413042INPUT:30433044- ``embedding`` -- two embeddings are available, and can be3045selected by setting ``embedding`` to 1 or 2.30463047EXAMPLES::30483049sage: g = graphs.LjubljanaGraph()3050sage: g.order()30511123052sage: g.size()30531683054sage: g.girth()3055103056sage: g.diameter()305783058sage: g.show(figsize=[10, 10]) # long time3059sage: graphs.LjubljanaGraph(embedding=2).show(figsize=[10, 10]) # long time30603061TESTS::30623063sage: graphs.LjubljanaGraph(embedding=3)3064Traceback (most recent call last):3065...3066ValueError: The value of embedding must be 1 or 2.3067"""30683069L = [47, -23, -31, 39, 25, -21, -31, -41, 25, 15, 29, -41, -19, 15,3070-49, 33, 39, -35, -21, 17, -33, 49, 41, 31, -15, -29, 41, 31,3071-15, -25, 21, 31, -51, -25, 23, 9, -17, 51, 35, -29, 21, -51,3072-39, 33, -9, -51, 51, -47, -33, 19, 51, -21, 29, 21, -31, -39]30733074from sage.graphs.generators.families import LCFGraph3075g = LCFGraph(112, L, 2)3076g.name("Ljubljana graph")30773078if embedding == 1:3079dh = HeawoodGraph().get_pos()30803081# Correspondence between the vertices of the Heawood Graph and3082# 8-sets of the Ljubljana Graph.30833084d = {30850: [1, 21, 39, 57, 51, 77, 95, 107],30861: [2, 22, 38, 58, 50, 78, 94, 106],30872: [3, 23, 37, 59, 49, 79, 93, 105],30883: [4, 24, 36, 60, 48, 80, 92, 104],30894: [5, 25, 35, 61, 15, 81, 91, 71],30909: [6, 26, 44, 62, 16, 82, 100, 72],309110: [7, 27, 45, 63, 17, 83, 101, 73],309211: [8, 28, 46, 64, 18, 84, 102, 74],309312: [9, 29, 47, 65, 19, 85, 103, 75],309413: [10, 30, 0, 66, 20, 86, 56, 76],30958: [11, 31, 111, 67, 99, 87, 55, 43],30967: [12, 32, 110, 68, 98, 88, 54, 42],30976: [13, 33, 109, 69, 97, 89, 53, 41],30985: [14, 34, 108, 70, 96, 90, 52, 40]3099}31003101# The vertices of each 8-set are plotted on a circle, and the3102# circles are slowly shifted to obtain a symmetric drawing.31033104for i, (u, vertices) in enumerate(d.iteritems()):3105_circle_embedding(g, vertices, center=dh[u], radius=.1,3106shift=8.*i/14)31073108return g31093110elif embedding == 2:3111return g31123113else:3114raise ValueError("The value of embedding must be 1 or 2.")31153116def M22Graph():3117r"""3118Returns the M22 graph.31193120The `M_{22}` graph is the unique strongly regular graph with parameters3121`v = 77, k = 16, \lambda = 0, \mu = 4`.31223123For more information on the `M_{22}` graph, see3124`<http://www.win.tue.nl/~aeb/graphs/M22.html>`_.31253126EXAMPLES::31273128sage: g = graphs.M22Graph()3129sage: g.order()3130773131sage: g.size()31326163133sage: g.is_strongly_regular(parameters = True)3134(77, 16, 0, 4)3135"""3136from sage.groups.perm_gps.permgroup_named import MathieuGroup3137sets = map(tuple,MathieuGroup(22).orbit((1,2,3,7,10,20), action = "OnSets"))3138g = Graph([sets, lambda x,y : not any(xx in y for xx in x)], name="M22 Graph")3139g.relabel()3140ordering = [0, 1, 3, 4, 5, 6, 7, 10, 12, 19, 20, 31, 2, 24, 35, 34, 22, 32,314136, 23, 27, 25, 40, 26, 16, 71, 61, 63, 50, 68, 39, 52, 48, 44,314269, 28, 9, 64, 60, 17, 38, 49, 45, 65, 14, 70, 72, 21, 43, 56,314333, 73, 58, 55, 41, 29, 66, 54, 76, 46, 67, 11, 51, 47, 62, 53,314415, 8, 18, 13, 59, 37, 30, 57, 75, 74, 42]31453146_circle_embedding(g, ordering)31473148return g31493150def MarkstroemGraph():3151r"""3152Returns the Markström Graph.31533154The Markström Graph is a cubic planar graph with no cycles of length 4 nor31558, but containing cycles of length 16. For more information, see the3156`Wolfram page about the Markström Graph3157<http://mathworld.wolfram.com/MarkstroemGraph.html>`_.31583159EXAMPLES::31603161sage: g = graphs.MarkstroemGraph()3162sage: g.order()3163243164sage: g.size()3165363166sage: g.is_planar()3167True3168sage: g.is_regular(3)3169True3170sage: g.subgraph_search(graphs.CycleGraph(4)) is None3171True3172sage: g.subgraph_search(graphs.CycleGraph(8)) is None3173True3174sage: g.subgraph_search(graphs.CycleGraph(16))3175Subgraph of (Markstroem Graph): Graph on 16 vertices3176"""3177g = Graph(name="Markstroem Graph")31783179g.add_cycle(range(9))3180g.add_path([0,9,10,11,2,1,11])3181g.add_path([3,12,13,14,5,4,14])3182g.add_path([6,15,16,17,8,7,17])3183g.add_cycle([10,9,18])3184g.add_cycle([12,13,19])3185g.add_cycle([15,16,20])3186g.add_cycle([21,22,23])3187g.add_edges([(19,22),(18,21),(20,23)])31883189_circle_embedding(g, sum([[9+3*i+j for j in range(3)]+[0]*2 for i in range(3)],[]), radius=.6, shift=.7)3190_circle_embedding(g, [18,19,20], radius=.35, shift=.25)3191_circle_embedding(g, [21,22,23], radius=.15, shift=.25)3192_circle_embedding(g, range(9))31933194return g31953196def McGeeGraph(embedding=2):3197r"""3198Returns the McGee Graph.31993200See the :wikipedia:`Wikipedia page on the McGee Graph3201<McGee_graph>`.32023203INPUT:32043205- ``embedding`` -- two embeddings are available, and can be3206selected by setting ``embedding`` to 1 or 2.32073208EXAMPLES::32093210sage: g = graphs.McGeeGraph()3211sage: g.order()3212243213sage: g.size()3214363215sage: g.girth()321673217sage: g.diameter()321843219sage: g.show()3220sage: graphs.McGeeGraph(embedding=1).show()32213222TESTS::32233224sage: graphs.McGeeGraph(embedding=3)3225Traceback (most recent call last):3226...3227ValueError: The value of embedding must be 1 or 2.3228"""32293230L = [47, -23, -31, 39, 25, -21, -31, -41, 25, 15, 29, -41, -19, 15,3231-49, 33, 39, -35, -21, 17, -33, 49, 41, 31, -15, -29, 41, 31,3232-15, -25, 21, 31, -51, -25, 23, 9, -17, 51, 35, -29, 21, -51,3233-39, 33, -9, -51, 51, -47, -33, 19, 51, -21, 29, 21, -31, -39]32343235from sage.graphs.generators.families import LCFGraph3236g = LCFGraph(24, [12, 7, -7], 8)3237g.name('McGee graph')32383239if embedding == 1:3240return g32413242elif embedding == 2:32433244o = [[7, 2, 13, 8, 19, 14, 1, 20],3245[5, 4, 11, 10, 17, 16, 23, 22],3246[3, 12, 9, 18, 15, 0, 21, 6]]32473248_circle_embedding(g, o[0], radius=1.5)3249_circle_embedding(g, o[1], radius=3, shift=-.5)3250_circle_embedding(g, o[2], radius=2.25, shift=.5)32513252return g32533254else:3255raise ValueError("The value of embedding must be 1 or 2.")32563257def McLaughlinGraph():3258r"""3259Returns the McLaughlin Graph.32603261The McLaughlin Graph is the unique strongly regular graph of parameters3262`(275, 112, 30, 56)`.32633264For more information on the McLaughlin Graph, see its web page on `Andries3265Brouwer's website <http://www.win.tue.nl/~aeb/graphs/McL.html>`_ which gives3266the definition that this method implements.32673268.. NOTE::32693270To create this graph you must have the gap_packages spkg installed.32713272EXAMPLES::32733274sage: g = graphs.McLaughlinGraph() # optional gap_packages3275sage: g.is_strongly_regular(parameters=True) # optional gap_packages3276(275, 112, 30, 56)3277sage: set(g.spectrum()) == {112, 2, -28} # optional gap_packages3278True3279"""3280from sage.combinat.designs.block_design import WittDesign3281from itertools import combinations3282from sage.sets.set import Set32833284blocks = WittDesign(23).blocks()3285blocks = map(Set, blocks)3286B = [b for b in blocks if 0 in b]3287C = [b for b in blocks if not 0 in b]3288g = graph.Graph()3289for b in B:3290for x in range(23):3291if not x in b:3292g.add_edge(b, x)32933294for b in C:3295for x in b:3296g.add_edge(b, x)32973298for b, bb in combinations(B, 2):3299if len(b & bb) == 1:3300g.add_edge(b, bb)33013302for c, cc in combinations(C, 2):3303if len(c & cc) == 1:3304g.add_edge(c, cc)33053306for b in B:3307for c in C:3308if len(b & c) == 3:3309g.add_edge(b, c)33103311g.relabel()3312g.name("McLaughlin")3313return g33143315def MoebiusKantorGraph():3316"""3317Returns a Moebius-Kantor Graph.33183319A Moebius-Kantor graph is a cubic symmetric graph. (See also the3320Heawood graph). It has 16 nodes and 24 edges. It is nonplanar and3321Hamiltonian. It has diameter = 4, girth = 6, and chromatic number =33222. It is identical to the Generalized Petersen graph, P[8,3].33233324PLOTTING: See the plotting section for the generalized Petersen graphs.33253326REFERENCES:33273328- [1] Weisstein, E. (1999). "Moebius-Kantor Graph - from3329Wolfram MathWorld". [Online] Available:3330http://mathworld.wolfram.com/Moebius-KantorGraph.html [2007,3331February 17]33323333EXAMPLES::33343335sage: MK = graphs.MoebiusKantorGraph()3336sage: MK3337Moebius-Kantor Graph: Graph on 16 vertices3338sage: MK.graph6_string()3339'OhCGKE?O@?ACAC@I?Q_AS'3340sage: (graphs.MoebiusKantorGraph()).show() # long time3341"""3342from sage.graphs.generators.families import GeneralizedPetersenGraph3343G=GeneralizedPetersenGraph(8,3)3344G.name("Moebius-Kantor Graph")3345return G33463347def MoserSpindle():3348r"""3349Returns the Moser spindle.33503351For more information, see this3352`MathWorld article on the Moser spindle <http://mathworld.wolfram.com/MoserSpindle.html>`_.33533354EXAMPLES:33553356The Moser spindle is a planar graph having 7 vertices and 11 edges. ::33573358sage: G = graphs.MoserSpindle(); G3359Moser spindle: Graph on 7 vertices3360sage: G.is_planar()3361True3362sage: G.order()336373364sage: G.size()33651133663367It is a Hamiltonian graph with radius 2, diameter 2, and girth 3. ::33683369sage: G.is_hamiltonian()3370True3371sage: G.radius()337223373sage: G.diameter()337423375sage: G.girth()3376333773378The Moser spindle has chromatic number 4 and its automorphism3379group is isomorphic to the dihedral group `D_4`. ::33803381sage: G.chromatic_number()338243383sage: ag = G.automorphism_group()3384sage: ag.is_isomorphic(DihedralGroup(4))3385True3386"""3387edge_dict = {33880: [1,4,5,6],33891: [2,5],33902: [3,5],33913: [4,6],33924: [6]}3393pos_dict = {33940: [0, 2],33951: [-1.90211303259031, 0.618033988749895],33962: [-1.17557050458495, -1.61803398874989],33973: [1.17557050458495, -1.61803398874989],33984: [1.90211303259031, 0.618033988749895],33995: [1, 0],34006: [-1, 0]}3401return Graph(edge_dict, pos=pos_dict, name="Moser spindle")340234033404def NauruGraph(embedding=2):3405"""3406Returns the Nauru Graph.34073408See the :wikipedia:`Wikipedia page on the Nauru Graph3409<Nauru_graph>`.34103411INPUT:34123413- ``embedding`` -- two embeddings are available, and can be3414selected by setting ``embedding`` to 1 or 2.34153416EXAMPLES::34173418sage: g = graphs.NauruGraph()3419sage: g.order()3420243421sage: g.size()3422363423sage: g.girth()342463425sage: g.diameter()342643427sage: g.show()3428sage: graphs.NauruGraph(embedding=1).show()34293430TESTS::34313432sage: graphs.NauruGraph(embedding=3)3433Traceback (most recent call last):3434...3435ValueError: The value of embedding must be 1 or 2.3436sage: graphs.NauruGraph(embedding=1).is_isomorphic(g)3437True3438"""34393440if embedding == 1:3441from sage.graphs.generators.families import LCFGraph3442g = LCFGraph(24, [5, -9, 7, -7, 9, -5], 4)3443g.name('Nauru Graph')3444return g3445elif embedding == 2:3446from sage.graphs.generators.families import GeneralizedPetersenGraph3447g = GeneralizedPetersenGraph(12, 5)3448g.name("Nauru Graph")3449return g3450else:3451raise ValueError("The value of embedding must be 1 or 2.")34523453def PappusGraph():3454"""3455Returns the Pappus graph, a graph on 18 vertices.34563457The Pappus graph is cubic, symmetric, and distance-regular.34583459EXAMPLES::34603461sage: G = graphs.PappusGraph()3462sage: G.show() # long time3463sage: L = graphs.LCFGraph(18, [5,7,-7,7,-7,-5], 3)3464sage: L.show() # long time3465sage: G.is_isomorphic(L)3466True3467"""3468pos_dict = {}3469for i in range(6):3470pos_dict[i] = [float(cos(pi/2 + ((2*pi)/6)*i)),\3471float(sin(pi/2 + ((2*pi)/6)*i))]3472pos_dict[6 + i] = [(2/3.0)*float(cos(pi/2 + ((2*pi)/6)*i)),\3473(2/3.0)*float(sin(pi/2 + ((2*pi)/6)*i))]3474pos_dict[12 + i] = [(1/3.0)*float(cos(pi/2 + ((2*pi)/6)*i)),\3475(1/3.0)*float(sin(pi/2 + ((2*pi)/6)*i))]3476return Graph({0:[1,5,6],1:[2,7],2:[3,8],3:[4,9],4:[5,10],\34775:[11],6:[13,17],7:[12,14],8:[13,15],9:[14,16],\347810:[15,17],11:[12,16],12:[15],13:[16],14:[17]},\3479pos=pos_dict, name="Pappus Graph")34803481def PoussinGraph():3482r"""3483Returns the Poussin Graph.34843485For more information on the Poussin Graph, see its corresponding `Wolfram3486page <http://mathworld.wolfram.com/PoussinGraph.html>`_.34873488EXAMPLES::34893490sage: g = graphs.PoussinGraph()3491sage: g.order()3492153493sage: g.is_planar()3494True3495"""3496g = Graph({2:[7,8,3,4],1:[7,6],0:[6,5,4],3:[5]},name="Poussin Graph")34973498g.add_cycle(range(3))3499g.add_cycle(range(3,9))3500g.add_cycle(range(9,14))3501g.add_path([8,12,7,11,6,10,5,9,3,13,8,12])3502g.add_edges([(14,i) for i in range(9,14)])3503_circle_embedding(g, range(3), shift=.75)3504_circle_embedding(g, range(3,9), radius=.4, shift=0)3505_circle_embedding(g, range(9,14), radius=.2, shift=.4)3506g.get_pos()[14] = (0,0)35073508return g35093510def PetersenGraph():3511"""3512The Petersen Graph is a named graph that consists of 10 vertices3513and 15 edges, usually drawn as a five-point star embedded in a3514pentagon.35153516The Petersen Graph is a common counterexample. For example, it is3517not Hamiltonian.35183519PLOTTING: See the plotting section for the generalized Petersen graphs.35203521EXAMPLES: We compare below the Petersen graph with the default3522spring-layout versus a planned position dictionary of [x,y]3523tuples::35243525sage: petersen_spring = Graph({0:[1,4,5], 1:[0,2,6], 2:[1,3,7], 3:[2,4,8], 4:[0,3,9], 5:[0,7,8], 6:[1,8,9], 7:[2,5,9], 8:[3,5,6], 9:[4,6,7]})3526sage: petersen_spring.show() # long time3527sage: petersen_database = graphs.PetersenGraph()3528sage: petersen_database.show() # long time3529"""3530from sage.graphs.generators.families import GeneralizedPetersenGraph3531P=GeneralizedPetersenGraph(5,2)3532P.name("Petersen graph")3533return P353435353536def RobertsonGraph():3537"""3538Returns the Robertson graph.35393540See the :wikipedia:`Wikipedia page on the Robertson Graph3541<Robertson_graph>`.35423543EXAMPLE::35443545sage: g = graphs.RobertsonGraph()3546sage: g.order()3547193548sage: g.size()3549383550sage: g.diameter()355133552sage: g.girth()355353554sage: g.charpoly().factor()3555(x - 4) * (x - 1)^2 * (x^2 + x - 5) * (x^2 + x - 1) * (x^2 - 3)^2 * (x^2 + x - 4)^2 * (x^2 + x - 3)^23556sage: g.chromatic_number()355733558sage: g.is_hamiltonian()3559True3560sage: g.is_vertex_transitive()3561False3562"""3563from sage.graphs.generators.families import LCFGraph3564lcf = [8, 4, 7, 4, 8, 5, 7, 4, 7, 8, 4, 5, 7, 8, 4, 8, 4, 8, 4]3565g = LCFGraph(19, lcf, 1)3566g.name("Robertson Graph")3567return g356835693570def SchlaefliGraph():3571r"""3572Returns the Schläfli graph.35733574The Schläfli graph is the only strongly regular graphs of parameters3575`(27,16,10,8)` (see [GodsilRoyle]_).35763577For more information, see the :wikipedia:`Wikipedia article on the3578Schläfli graph <Schläfli_graph>`.35793580.. SEEALSO::35813582:meth:`Graph.is_strongly_regular` -- tests whether a graph is strongly3583regular and/or returns its parameters.35843585.. TODO::35863587Find a beautiful layout for this beautiful graph.35883589EXAMPLE:35903591Checking that the method actually returns the Schläfli graph::35923593sage: S = graphs.SchlaefliGraph()3594sage: S.is_strongly_regular(parameters = True)3595(27, 16, 10, 8)35963597The graph is vertex-transitive::35983599sage: S.is_vertex_transitive()3600True36013602The neighborhood of each vertex is isomorphic to the complement of the3603Clebsch graph::36043605sage: neighborhood = S.subgraph(vertices = S.neighbors(0))3606sage: graphs.ClebschGraph().complement().is_isomorphic(neighborhood)3607True3608"""3609from sage.graphs.graph import Graph3610G = Graph('ZBXzr|}^z~TTitjLth|dmkrmsl|if}TmbJMhrJX]YfFyTbmsseztKTvyhDvw')3611order = [1,8,5,10,2,6,11,15,17,13,18,12,9,24,25,3,26,7,16,20,23,0,21,14,22,4,19]3612_circle_embedding(G, order)3613G.name("Schläfli graph")3614return G36153616def ShrikhandeGraph():3617"""3618Returns the Shrikhande graph.36193620For more information, see the `MathWorld article on the Shrikhande graph3621<http://mathworld.wolfram.com/ShrikhandeGraph.html>`_ or the3622:wikipedia:`Wikipedia article on the Shrikhande graph <Shrikhande_graph>`.36233624.. SEEALSO::36253626:meth:`Graph.is_strongly_regular` -- tests whether a graph is strongly3627regular and/or returns its parameters.36283629EXAMPLES:36303631The Shrikhande graph was defined by S. S. Shrikhande in 1959. It has3632`16` vertices and `48` edges, and is strongly regular of degree `6` with3633parameters `(2,2)`::36343635sage: G = graphs.ShrikhandeGraph(); G3636Shrikhande graph: Graph on 16 vertices3637sage: G.order()3638163639sage: G.size()3640483641sage: G.is_regular(6)3642True3643sage: set([ len([x for x in G.neighbors(i) if x in G.neighbors(j)])3644....: for i in range(G.order())3645....: for j in range(i) ])3646set([2])36473648It is non-planar, and both Hamiltonian and Eulerian::36493650sage: G.is_planar()3651False3652sage: G.is_hamiltonian()3653True3654sage: G.is_eulerian()3655True36563657It has radius `2`, diameter `2`, and girth `3`::36583659sage: G.radius()366023661sage: G.diameter()366223663sage: G.girth()3664336653666Its chromatic number is `4` and its automorphism group is of order3667`192`::36683669sage: G.chromatic_number()367043671sage: G.automorphism_group().cardinality()367219236733674It is an integral graph since it has only integral eigenvalues::36753676sage: G.characteristic_polynomial().factor()3677(x - 6) * (x - 2)^6 * (x + 2)^936783679It is a toroidal graph, and its embedding on a torus is dual to an3680embedding of the Dyck graph (:meth:`DyckGraph <GraphGenerators.DyckGraph>`).3681"""3682pos_dict = {}3683for i in range(8):3684pos_dict[i] = [float(cos((2*i) * pi/8)),3685float(sin((2*i) * pi/8))]3686pos_dict[8 + i] = [0.5 * pos_dict[i][0],36870.5 * pos_dict[i][1]]3688edge_dict = {36890O00: [0O06, 0O07, 0O01, 0O02, 0O11, 0O17],36900O01: [0O07, 0O00, 0O02, 0O03, 0O12, 0O10],36910O02: [0O00, 0O01, 0O03, 0O04, 0O13, 0O11],36920O03: [0O01, 0O02, 0O04, 0O05, 0O14, 0O12],36930O04: [0O02, 0O03, 0O05, 0O06, 0O15, 0O13],36940O05: [0O03, 0O04, 0O06, 0O07, 0O16, 0O14],36950O06: [0O04, 0O05, 0O07, 0O00, 0O17, 0O15],36960O07: [0O05, 0O06, 0O00, 0O01, 0O10, 0O16],369736980O10: [0O12, 0O13, 0O15, 0O16, 0O07, 0O01],36990O11: [0O13, 0O14, 0O16, 0O17, 0O00, 0O02],37000O12: [0O14, 0O15, 0O17, 0O10, 0O01, 0O03],37010O13: [0O15, 0O16, 0O10, 0O11, 0O02, 0O04],37020O14: [0O16, 0O17, 0O11, 0O12, 0O03, 0O05],37030O15: [0O17, 0O10, 0O12, 0O13, 0O04, 0O06],37040O16: [0O10, 0O11, 0O13, 0O14, 0O05, 0O07],37050O17: [0O11, 0O12, 0O14, 0O15, 0O06, 0O00]3706}37073708return Graph(edge_dict, pos=pos_dict, name="Shrikhande graph")37093710def SylvesterGraph():3711"""3712Returns the Sylvester Graph.37133714This graph is obtained from the Hoffman Singleton graph by considering the3715graph induced by the vertices at distance two from the vertices of an (any)3716edge.37173718For more information on the Sylvester graph, see3719`<http://www.win.tue.nl/~aeb/graphs/Sylvester.html>`_.37203721.. SEEALSO::37223723* :meth:`~sage.graphs.graph_generators.GraphGenerators.HoffmanSingletonGraph`.37243725EXAMPLE::37263727sage: g = graphs.SylvesterGraph(); g3728Sylvester Graph: Graph on 36 vertices3729sage: g.order()3730363731sage: g.size()3732903733sage: g.is_regular(k=5)3734True3735"""3736g = HoffmanSingletonGraph()3737e = g.edge_iterator(labels = False).next()3738g.delete_vertices(g.neighbors(e[0]) + g.neighbors(e[1]))3739g.relabel()3740ordering = [0, 1, 2, 4, 5, 9, 16, 35, 15, 18, 20, 30, 22, 6, 33, 32, 14,374110, 28, 29, 7, 24, 23, 26, 19, 12, 13, 21, 11, 31, 3, 27, 25,374217, 8, 34]3743_circle_embedding(g,ordering, shift=.5)3744g.name("Sylvester Graph")3745return g37463747def SimsGewirtzGraph():3748"""3749Returns the Sims-Gewirtz Graph.37503751This graph is obtained from the Higman Sims graph by considering the graph3752induced by the vertices at distance two from the vertices of an (any)3753edge. It is the only strongly regular graph with parameters `v = 56, k = 10,3754\lambda = 0, \mu = 2`37553756For more information on the Sylvester graph, see3757`<http://www.win.tue.nl/~aeb/graphs/Sims-Gewirtz.html>`_ or its3758:wikipedia:`Wikipedia page <Gewirtz graph>`.37593760.. SEEALSO::37613762* :meth:`~sage.graphs.graph_generators.GraphGenerators.HigmanSimsGraph`.37633764EXAMPLE::37653766sage: g = graphs.SimsGewirtzGraph(); g3767Sims-Gewirtz Graph: Graph on 56 vertices3768sage: g.order()3769563770sage: g.size()37712803772sage: g.is_strongly_regular(parameters = True)3773(56, 10, 0, 2)37743775"""3776g = HigmanSimsGraph()3777e = g.edge_iterator(labels = False).next()3778g.delete_vertices(g.neighbors(e[0]) + g.neighbors(e[1]))3779g.relabel()3780ordering = [0, 2, 3, 4, 6, 7, 8, 17, 1, 41, 49, 5, 22, 26, 11, 27, 15, 47,378153, 52, 38, 43, 44, 18, 20, 32, 19, 42, 54, 36, 51, 30, 33, 35,378237, 28, 34, 12, 29, 23, 55, 25, 40, 24, 9, 14, 48, 39, 45, 16,378313, 21, 31, 50, 10, 46]3784_circle_embedding(g,ordering)3785g.name("Sims-Gewirtz Graph")3786return g37873788def SousselierGraph():3789r"""3790Returns the Sousselier Graph.37913792The Sousselier graph is a hypohamiltonian graph on 16 vertices and 273793edges. For more information, see the corresponding `Wikipedia page (in3794French) <http://fr.wikipedia.org/wiki/Graphe_de_Sousselier>`_.37953796EXAMPLES::37973798sage: g = graphs.SousselierGraph()3799sage: g.order()3800163801sage: g.size()3802273803sage: g.radius()380423805sage: g.diameter()380633807sage: g.automorphism_group().cardinality()380823809sage: g.is_hamiltonian()3810False3811sage: g.delete_vertex(g.random_vertex())3812sage: g.is_hamiltonian()3813True3814"""3815g = Graph(name="Sousselier Graph")38163817g.add_cycle(range(15))3818g.add_path([12,8,3,14])3819g.add_path([9,5,0,11])3820g.add_edge(6,2)3821g.add_edges([(15,i) for i in range(15) if i%3==1])38223823_circle_embedding(g, range(15), shift=-.25)3824g.get_pos()[15] = (0,0)38253826return g38273828def SzekeresSnarkGraph():3829r"""3830Returns the Szekeres Snark Graph.38313832The Szekeres graph is a snark with 50 vertices and 75 edges. For more3833information on this graph, see the :wikipedia:`Szekeres_snark`.38343835EXAMPLES::38363837sage: g = graphs.SzekeresSnarkGraph()3838sage: g.order()3839503840sage: g.size()3841753842sage: g.chromatic_number()384333844"""3845g = Graph(name="Szekeres Snark Graph")38463847for i in range(5):3848g.add_cycle([(i,j) for j in range(9)])3849g.delete_edge((i,0),(i,8))3850g.add_edge((i,1),i)3851g.add_edge((i,4),i)3852g.add_edge((i,7),i)3853g.add_edge((i,0),(i,5))3854g.add_edge((i,8),(i,3))38553856g.add_edge((i,0),((i+1)%5,8))3857g.add_edge((i,6),((i+2)%5,2))3858_circle_embedding(g, [(i,j) for j in range(9)],3859radius=.3,3860center=(cos(2*(i+.25)*pi/5),sin(2*(i+.25)*pi/5)),3861shift=5.45+1.8*i)38623863_circle_embedding(g, range(5), radius=1, shift=.25)38643865g.relabel()3866return g386738683869def ThomsenGraph():3870"""3871Returns the Thomsen Graph.38723873The Thomsen Graph is actually a complete bipartite graph with `(n1, n2) =3874(3, 3)`. It is also called the Utility graph.38753876PLOTTING: See CompleteBipartiteGraph.38773878EXAMPLES::38793880sage: T = graphs.ThomsenGraph()3881sage: T3882Thomsen graph: Graph on 6 vertices3883sage: T.graph6_string()3884'EFz_'3885sage: (graphs.ThomsenGraph()).show() # long time3886"""3887pos_dict = {0:(-1,1),1:(0,1),2:(1,1),3:(-1,0),4:(0,0),5:(1,0)}3888import networkx3889G = networkx.complete_bipartite_graph(3,3)3890return Graph(G, pos=pos_dict, name="Thomsen graph")38913892def TietzeGraph():3893r"""3894Returns the Tietze Graph.38953896For more information on the Tietze Graph, see the3897:wikipedia:`Tietze's_graph`.38983899EXAMPLES::39003901sage: g = graphs.TietzeGraph()3902sage: g.order()3903123904sage: g.size()3905183906sage: g.diameter()390733908sage: g.girth()390933910sage: g.automorphism_group().cardinality()3911123912sage: g.automorphism_group().is_isomorphic(groups.permutation.Dihedral(6))3913True3914"""3915g = Graph([(0,9),(3,10),(6,11),(1,5),(2,7),(4,8),(7,2)], name="Tietze Graph")3916g.add_cycle(range(9))3917g.add_cycle([9,10,11])3918_circle_embedding(g,range(9))3919_circle_embedding(g,[9,10,11],radius=.5)39203921return g39223923def Tutte12Cage():3924r"""3925Returns Tutte's 12-Cage.39263927See the :wikipedia:`Wikipedia page on the Tutte 12-Cage3928<Tutte_12-cage>`.39293930EXAMPLES::39313932sage: g = graphs.Tutte12Cage()3933sage: g.order()39341263935sage: g.size()39361893937sage: g.girth()3938123939sage: g.diameter()394063941sage: g.show()3942"""3943L = [17, 27, -13, -59, -35, 35, -11, 13, -53, 53, -27, 21, 57, 11,3944-21, -57, 59, -17]39453946from sage.graphs.generators.families import LCFGraph3947g = LCFGraph(126, L, 7)3948g.name("Tutte 12-Cage")3949return g39503951def TutteCoxeterGraph(embedding=2):3952r"""3953Returns the Tutte-Coxeter graph.39543955See the :wikipedia:`Wikipedia page on the Tutte-Coxeter Graph3956<Tutte-Coxeter_graph>`.39573958INPUT:39593960- ``embedding`` -- two embeddings are available, and can be3961selected by setting ``embedding`` to 1 or 2.39623963EXAMPLES::39643965sage: g = graphs.TutteCoxeterGraph()3966sage: g.order()3967303968sage: g.size()3969453970sage: g.girth()397183972sage: g.diameter()397343974sage: g.show()3975sage: graphs.TutteCoxeterGraph(embedding=1).show()39763977TESTS::39783979sage: graphs.TutteCoxeterGraph(embedding=3)3980Traceback (most recent call last):3981...3982ValueError: The value of embedding must be 1 or 2.3983"""39843985from sage.graphs.generators.families import LCFGraph3986g = LCFGraph(30, [-13, -9, 7, -7, 9, 13], 5)3987g.name("Tutte-Coxeter graph")39883989if embedding == 1:3990d = {39910: [1, 3, 5, 7, 29],39921: [2, 4, 6, 28, 0],39932: [8, 18, 26, 22, 12],39943: [9, 13, 23, 27, 17],39954: [11, 15, 21, 25, 19],39965: [10, 14, 24, 20, 16]3997}39983999_circle_embedding(g, d[0], center=(-1, 1), radius=.25)4000_circle_embedding(g, d[1], center=(1, 1), radius=.25)4001_circle_embedding(g, d[2], center=(-.8, 0), radius=.25, shift=2.5)4002_circle_embedding(g, d[3], center=(1.2, 0), radius=.25)4003_circle_embedding(g, d[4], center=(-1, -1), radius=.25, shift=2)4004_circle_embedding(g, d[5], center=(1, -1), radius=.25)40054006return g40074008elif embedding == 2:4009return g40104011else:4012raise ValueError("The value of embedding must be 1 or 2.")40134014def TutteGraph():4015r"""4016Returns the Tutte Graph.40174018The Tutte graph is a 3-regular, 3-connected, and planar non-hamiltonian4019graph. For more information on the Tutte Graph, see the4020:wikipedia:`Tutte_graph`.40214022EXAMPLES::40234024sage: g = graphs.TutteGraph()4025sage: g.order()4026464027sage: g.size()4028694029sage: g.is_planar()4030True4031sage: g.vertex_connectivity() # long403234033sage: g.girth()403444035sage: g.automorphism_group().cardinality()403634037sage: g.is_hamiltonian()4038False4039"""4040g = Graph(name="Tutte Graph")4041from sage.graphs.graph_plot import _circle_embedding40424043g.add_cycle([(i,j) for i in range(3) for j in range(3) ])4044for i in range(3):4045g.add_cycle([(i,j) for j in range(9)])4046g.add_cycle([(i,j) for j in range(9,14)])4047g.add_edge((i,5),0)4048g.add_edge((i,13),(i,3))4049g.add_edge((i,12),(i,1))4050g.add_edge((i,11),(i,8))4051g.add_edge((i,10),(i,7))4052g.add_edge((i,6),(i,14))4053g.add_edge((i,4),(i,14))4054g.add_edge((i,9),(i,14))40554056_circle_embedding(g, [(i,j) for i in range(3) for j in range(6)], shift=.5)4057_circle_embedding(g, [(i,14) for i in range(3) ], radius=.3,shift=.25)40584059for i in range(3):4060_circle_embedding(g, [(i,j) for j in range(3,9)]+[0]*5,4061shift=3.7*(i-2)+.75,4062radius=.4,4063center=(.6*cos(2*(i+.25)*pi/3),.6*sin(2*(i+.25)*pi/3)))4064_circle_embedding(g, [(i,j) for j in range(9,14)],4065shift=1.7*(i-2)+1,4066radius=.2,4067center=(.6*cos(2*(i+.25)*pi/3),.6*sin(2*(i+.25)*pi/3)))40684069g.get_pos()[0] = (0,0)40704071return g40724073def WagnerGraph():4074"""4075Returns the Wagner Graph.40764077See the :wikipedia:`Wikipedia page on the Wagner Graph4078<Wagner_graph>`.40794080EXAMPLES::40814082sage: g = graphs.WagnerGraph()4083sage: g.order()408484085sage: g.size()4086124087sage: g.girth()408844089sage: g.diameter()409024091sage: g.show()4092"""4093from sage.graphs.generators.families import LCFGraph4094g = LCFGraph(8, [4], 8)4095g.name("Wagner Graph")4096return g40974098def WatkinsSnarkGraph():4099r"""4100Returns the Watkins Snark Graph.41014102The Watkins Graph is a snark with 50 vertices and 75 edges. For more4103information, see the :wikipedia:`Watkins_snark`.41044105EXAMPLES::41064107sage: g = graphs.WatkinsSnarkGraph()4108sage: g.order()4109504110sage: g.size()4111754112sage: g.chromatic_number()411334114"""4115g = Graph(name="Watkins Snark Graph")41164117for i in range(5):4118g.add_cycle([(i,j) for j in range(9)])4119_circle_embedding(g,4120[(i,j) for j in range(4)]+[0]*2+[(i,4)]+[0]*2+[(i,j) for j in range(5,9)],4121radius=.3,4122center=(cos(2*(i+.25)*pi/5),sin(2*(i+.25)*pi/5)),4123shift=2.7*i+7.55)4124g.add_edge((i,5),((i+1)%5,0))4125g.add_edge((i,8),((i+2)%5,3))4126g.add_edge((i,1),i)4127g.add_edge((i,7),i)4128g.add_edge((i,4),i)4129g.add_edge((i,6),(i,2))41304131_circle_embedding(g, range(5), shift=.25, radius=1.1)4132return g41334134def WienerArayaGraph():4135r"""4136Returns the Wiener-Araya Graph.41374138The Wiener-Araya Graph is a planar hypohamiltonian graph on 42 vertices and413967 edges. For more information, see the `Wolfram Page on the Wiener-Araya4140Graph <http://mathworld.wolfram.com/Wiener-ArayaGraph.html>`_ or its4141`(french) Wikipedia page4142<http://fr.wikipedia.org/wiki/Graphe_de_Wiener-Araya>`_.41434144EXAMPLES::41454146sage: g = graphs.WienerArayaGraph()4147sage: g.order()4148424149sage: g.size()4150674151sage: g.girth()415244153sage: g.is_planar()4154True4155sage: g.is_hamiltonian() # not tested -- around 30s long4156False4157sage: g.delete_vertex(g.random_vertex())4158sage: g.is_hamiltonian()4159True4160"""4161g = Graph(name="Wiener-Araya Graph")4162from sage.graphs.graph_plot import _circle_embedding41634164g.add_cycle([(0,i) for i in range(4)])4165g.add_cycle([(1,i) for i in range(12)])4166g.add_cycle([(2,i) for i in range(20)])4167g.add_cycle([(3,i) for i in range(6)])4168_circle_embedding(g, [(0,i) for i in range(4)], shift=.5)4169_circle_embedding(g,4170sum([[(1,3*i),(1,3*i+1)]+[0]*3+[(1,3*i+2)]+[0]*3 for i in range(4)],[]),4171shift=4,4172radius=.65)4173_circle_embedding(g, [(2,i) for i in range(20)], radius=.5)4174_circle_embedding(g, [(3,i) for i in range(6)], radius=.3, shift=.5)41754176for i in range(4):4177g.delete_edge((1,3*i),(1,3*i+1))4178g.add_edge((1,3*i),(0,i))4179g.add_edge((1,3*i+1),(0,i))4180g.add_edge((2,5*i+2),(1,3*i))4181g.add_edge((2,5*i+3),(1,3*i+1))4182g.add_edge((2,(5*i+5)%20),(1,3*i+2))4183g.add_edge((2,(5*i+1)%20),(3,i+(i>=1)+(i>=3)))4184g.add_edge((2,(5*i+4)%20),(3,i+(i>=1)+(i>=3)))41854186g.delete_edge((3,1),(3,0))4187g.add_edge((3,1),(2,4))4188g.delete_edge((3,4),(3,3))4189g.add_edge((3,4),(2,14))4190g.add_edge((3,1),(3,4))41914192g.get_pos().pop(0)4193g.relabel()4194return g419541964197