# Ticket #12945: trac_12945-newembedding.patch

File trac_12945-newembedding.patch, 11.6 KB (added by kini, 7 years ago)

apply to \$SAGE_ROOT/devel/sage

• ## sage/graphs/graph_generators.py

```# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1336983643 -7200
# Node ID 267492bb09f3afab1a62479bb5a15874a5287eca
# Parent  340df701e0954f1cc121ece3534a42937104b07e
A new embedding for graphs.Balaban11Cage

diff --git a/sage/graphs/graph_generators.py b/sage/graphs/graph_generators.py```
 a return g def Balaban11Cage(self): def Balaban11Cage(self, embedding = 1): r""" Returns the Balaban 11-cage. For more information, see this `Wikipedia article on the Balaban 11-cage `_. """ pos_dict = {} for j in range(8): for i in range(8): pos_dict[str(j) + str(i)]= [ 0.8 * float(cos(2*((8*j + i)*pi/64 + pi/128))), 0.8 * float(sin(2*((8*j + i)*pi/64 + pi/128))) ] for i in range(4): pos_dict['1' + str(j) + str(i)] = [ 1.1 * float(cos(2*((4*j + i)*pi/32 + pi/64))), 1.1 * float(sin(2*((4*j + i)*pi/32 + pi/64))) ] for i in range(2): pos_dict['1' + str(j) + str(i + 4)] = [ 1.4 * float(cos(2*((2*j + i)*pi/16 + pi/32))), 1.4 * float(sin(2*((2*j + i)*pi/16 + pi/32))) ] edge_dict = { "00": ["11"], "01": ["10"],   "02": ["53"], "03": ["52"], "11": ["20"], "10": ["21"],   "53": ["22"], "52": ["23"], "20": ["31"], "21": ["30"],   "22": ["33"], "23": ["32"], "31": ["40"], "30": ["41"],   "33": ["43"], "32": ["42"], "40": ["50"], "41": ["51"],   "43": ["12"], "42": ["13"], "50": ["61"], "51": ["60"],   "12": ["63"], "13": ["62"], "61": ["70"], "60": ["71"],   "63": ["72"], "62": ["73"], "70": ["01"], "71": ["00"],   "72": ["03"], "73": ["02"], "04": ["35"], "05": ["34"],   "06": ["37"], "07": ["36"], "35": ["64"], "34": ["65"],   "37": ["66"], "36": ["67"], "64": ["55"], "65": ["54"],   "66": ["17"], "67": ["16"], "55": ["45"], "54": ["44"],   "17": ["46"], "16": ["47"], "45": ["74"], "44": ["75"],   "46": ["76"], "47": ["77"], "74": ["25"], "75": ["24"],   "76": ["27"], "77": ["26"], "25": ["14"], "24": ["15"],   "27": ["56"], "26": ["57"], "14": ["05"], "15": ["04"],   "56": ["07"], "57": ["06"], "100": ["03", "04"],   "110": ["10", "12"], "101": ["01", "06"],   "111": ["11", "13"], "102": ["00", "07"],   "112": ["14", "16"], "103": ["02", "05"],   "113": ["15", "17"], "120": ["22", "24"],   "130": ["33", "36"], "121": ["20", "26"],   "131": ["32", "37"], "122": ["21", "27"],   "132": ["31", "34"], "123": ["23", "25"],   "133": ["30", "35"], "140": ["43", "45"],   "150": ["50", "52"], "141": ["40", "46"],   "151": ["51", "53"], "142": ["41", "47"],   "152": ["54", "56"], "143": ["42", "44"],   "153": ["55", "57"], "160": ["60", "66"],   "170": ["73", "76"], "161": ["63", "65"],   "171": ["72", "77"], "162": ["62", "64"],   "172": ["71", "74"], "163": ["61", "67"],   "173": ["70", "75"], "104": ["100", "102", "105"],   "114": ["110", "111", "115"], "105": ["101", "103", "104"],   "115": ["112", "113", "114"], "124": ["120", "121", "125"],   "134": ["130", "131", "135"], "125": ["122", "123", "124"],   "135": ["132", "133", "134"], "144": ["140", "141", "145"],   "154": ["150", "151", "155"], "145": ["142", "143", "144"],   "155": ["152", "153", "154"], "164": ["160", "161", "165"],   "174": ["170", "171", "175"], "165": ["162", "163", "164"],   "175": ["172", "173", "174"] } return graph.Graph(edge_dict, pos=pos_dict, name="Balaban 11-cage") For more information, see this :wikipedia:`Wikipedia article on the Balaban 11-cage `. INPUT: - ``embedding`` -- three embeddings are available, and can be selected by setting ``embedding`` to be 1, 2, or 3. - The first embedding is the one appearing on page 9 of the Fifth Annual Graph Drawing Contest report [FAGDC]_. - The second embedding has been produced just for Sage and is meant to emphasize the automorphism group's 6 orbits. - The last embedding is the default one produced by the :meth:`LCFGraph` constructor. .. NOTE:: The vertex labeling changes according to the value of ``embedding=1``. EXAMPLES: Basic properties:: sage: g = graphs.Balaban11Cage() sage: g.order() 112 sage: g.size() 168 sage: g.girth() 11 sage: g.diameter() 8 sage: g.automorphism_group().cardinality() 64 Our many embeddings:: sage: graphs.Balaban11Cage(embedding=1).show(figsize=[10,10]) sage: graphs.Balaban11Cage(embedding=2).show(figsize=[10,10]) sage: graphs.Balaban11Cage(embedding=3).show(figsize=[10,10]) REFERENCES: .. [FAGDC] Fifth Annual Graph Drawing Contest P. Eaded, J. Marks, P.Mutzel, S. North http://www.merl.com/papers/docs/TR98-16.pdf """ if embedding == 1: pos_dict = {} for j in range(8): for i in range(8): pos_dict[str(j) + str(i)]= [ 0.8 * float(cos(2*((8*j + i)*pi/64 + pi/128))), 0.8 * float(sin(2*((8*j + i)*pi/64 + pi/128))) ] for i in range(4): pos_dict['1' + str(j) + str(i)] = [ 1.1 * float(cos(2*((4*j + i)*pi/32 + pi/64))), 1.1 * float(sin(2*((4*j + i)*pi/32 + pi/64))) ] for i in range(2): pos_dict['1' + str(j) + str(i + 4)] = [ 1.4 * float(cos(2*((2*j + i)*pi/16 + pi/32))), 1.4 * float(sin(2*((2*j + i)*pi/16 + pi/32))) ] edge_dict = { "00": ["11"], "01": ["10"],   "02": ["53"], "03": ["52"], "11": ["20"], "10": ["21"],   "53": ["22"], "52": ["23"], "20": ["31"], "21": ["30"],   "22": ["33"], "23": ["32"], "31": ["40"], "30": ["41"],   "33": ["43"], "32": ["42"], "40": ["50"], "41": ["51"],   "43": ["12"], "42": ["13"], "50": ["61"], "51": ["60"],   "12": ["63"], "13": ["62"], "61": ["70"], "60": ["71"],   "63": ["72"], "62": ["73"], "70": ["01"], "71": ["00"],   "72": ["03"], "73": ["02"], "04": ["35"], "05": ["34"],   "06": ["37"], "07": ["36"], "35": ["64"], "34": ["65"],   "37": ["66"], "36": ["67"], "64": ["55"], "65": ["54"],   "66": ["17"], "67": ["16"], "55": ["45"], "54": ["44"],   "17": ["46"], "16": ["47"], "45": ["74"], "44": ["75"],   "46": ["76"], "47": ["77"], "74": ["25"], "75": ["24"],   "76": ["27"], "77": ["26"], "25": ["14"], "24": ["15"],   "27": ["56"], "26": ["57"], "14": ["05"], "15": ["04"],   "56": ["07"], "57": ["06"], "100": ["03", "04"],   "110": ["10", "12"], "101": ["01", "06"],   "111": ["11", "13"], "102": ["00", "07"],   "112": ["14", "16"], "103": ["02", "05"],   "113": ["15", "17"], "120": ["22", "24"],   "130": ["33", "36"], "121": ["20", "26"],   "131": ["32", "37"], "122": ["21", "27"],   "132": ["31", "34"], "123": ["23", "25"],   "133": ["30", "35"], "140": ["43", "45"],   "150": ["50", "52"], "141": ["40", "46"],   "151": ["51", "53"], "142": ["41", "47"],   "152": ["54", "56"], "143": ["42", "44"],   "153": ["55", "57"], "160": ["60", "66"],   "170": ["73", "76"], "161": ["63", "65"],   "171": ["72", "77"], "162": ["62", "64"],   "172": ["71", "74"], "163": ["61", "67"],   "173": ["70", "75"], "104": ["100", "102", "105"],   "114": ["110", "111", "115"], "105": ["101", "103", "104"],   "115": ["112", "113", "114"], "124": ["120", "121", "125"],   "134": ["130", "131", "135"], "125": ["122", "123", "124"],   "135": ["132", "133", "134"], "144": ["140", "141", "145"],   "154": ["150", "151", "155"], "145": ["142", "143", "144"],   "155": ["152", "153", "154"], "164": ["160", "161", "165"],   "174": ["170", "171", "175"], "165": ["162", "163", "164"],   "175": ["172", "173", "174"] } return graph.Graph(edge_dict, pos=pos_dict, name="Balaban 11-cage") elif embedding == 2 or embedding == 3: L = [44, 26, -47, -15, 35, -39, 11, -27, 38, -37, 43, 14, 28, 51, -29, -16, 41, -11, -26, 15, 22, -51, -35, 36, 52, -14, -33, -26, -46, 52, 26, 16, 43, 33, -15, 17, -53, 23, -42, -35, -28, 30, -22, 45, -44, 16, -38, -16, 50, -55, 20, 28, -17, -43, 47, 34, -26, -41, 11, -36, -23, -16, 41, 17, -51, 26, -33, 47, 17, -11, -20, -30, 21, 29, 36, -43, -52, 10, 39, -28, -17, -52, 51, 26, 37, -17, 10, -10, -45, -34, 17, -26, 27, -21, 46, 53, -10, 29, -50, 35, 15, -47, -29, -41, 26, 33, 55, -17, 42, -26, -36, 16] g = graphs.LCFGraph(112, L, 1) g.name("Balaban 11-cage") if embedding == 3: return g v1 = [34, 2, 54, 43, 66, 20, 89, 100, 72, 76, 6, 58, 16, 78, 74, 70, 36, 94, 27, 25, 10, 8, 45, 60, 14, 64, 80, 82, 109, 107, 49, 98] v2 = [88, 3, 19, 55, 67, 42, 101, 33, 77, 5, 17, 57, 69, 71, 73, 75, 11, 61, 28, 9, 37, 26, 46, 95, 13, 63, 81, 83, 108, 106, 48, 97] l1 = [35, 93, 1, 24, 53, 7, 44, 59, 15, 65, 79, 21, 110, 90, 50, 99] l2 = [87, 4, 18, 56, 68, 41, 102, 32, 12, 62, 29, 84, 38, 105, 47, 96] d = g.get_pos() for i,v in enumerate(v1): d[v] = (-2, 16.5-i) for i,v in enumerate(l1): d[v] = (-10, 8-i) for i,v in enumerate(l2): d[v] = (10, 8.5-i) for i,v in enumerate(v2): d[v] = (2, 16.5-i) for i,v in enumerate([0, 111, 92, 91, 52, 51, 23, 22]): d[v] = (-20, 14.5-4*i) for i,v in enumerate([104, 103, 86, 85, 40, 39, 31, 30]): d[v] = (20, 14.5-4*i) return g else: raise ValueError("The value of embedding must be either 1 or 2") def BidiakisCube(self): r"""