 SharedBranched Covers Group / DessinGen.sagewsOpen in CoCalc
Views : 44
def Graf(S0, S1): D={} #empty graph G={} #edited graph that we add to verts={} #opening an empty graph graph=Graph(D, multiedges=True) #adds edges and vertices to the graph #S0 and S1 are lists of lists def Dessin(S0, S1): numVertices = len(S0)+len(S1) #creating dictionary G of vertices with neighboring edges in counterclockwise order for i in range(numVertices): G[i]=(S0+S1)[i] verts[i]=[] #iterate over black vertices for i in range(len(S0)): #iterate over edges connected to black vertices for j in range(len(S0[i])): #iterate over white vertices for k in range(len(S1)): #check if black and white vertices have an edge in common if S0[i][j] in S1[k]: #if they have an edge in common connect the vertices with the correct edge labeling graph.add_edge(i,k+len(S0),S0[i][j]) print('dictionary of neighboring edges:') print(G) #creating dictionary with vertices as keys and neighboring vertices in counterclockwise order for i in range(numVertices): for j in range(len(G[i])): for k in range(numVertices): if i!=k: for l in range(len(G[k])): if G[i][j] in G[k]: if k not in verts[i]: verts[i].append(k) #flip order of vertices so that we're counterclockwise. for i in range(len(verts)): L=[] for j in range(len(verts[i])): L.append(verts[i][(len(verts[i]))-j-1]) verts[i]=L #all the vertices in S0 are black, all the vertices in S1 are white def color(S0, S1): grey=[] white=[] for i in range(len(S0)): grey.append(i) for i in range(len(S1)): white.append(i+len(S0)) return [grey,white] #call and color the graph Dessin(S0, S1) color(S0, S1) #keep a certain ordering graph.set_embedding(verts) graph.graphplot(edge_labels=True, vertex_colors={'grey': color(S0,S1),'white':color(S0,S1)}, vertex_labels=True, edge_labels_background='transparent').show() return(graph) ####### Degree N=1 #Graf([],[]) ####### Degree N=2 # Graf([[1,2]],[,]) ####### Degree N=3 # Graf([[1,3,2]],[,,]) ##Wrong Direction # Graf([,[2,3]],[,[1,2]]) ####### Degree N=4 # Graf([[1,4,3,2]],[,,,]) ##Doesn't Work # Graf([,[1,4,2]],[,,[3,4]]) # Graf([[1,2],[3,4]],[,,[1,3]]) # Graf([,[1,4,2]],[[1,2],[3,4]]) ###MULTIEDGES # Graf([,[1,3,2]],[,[1,4,2]]) ###MULTIEDGES # Graf([[1,2],[3,4]],[[1,4],[2,3]]) ####### Degree N=5 # Graf([[1,5,4,3,2]],[,,,,]) ###Doesn't Work # Graf([,[1,5,3,2]],[,,,[4,5]]) # Graf([[4,5],[1,3,2]],[,,,[1,4]]) # Graf([,,[1,5,2]],[,,[3,5,4]]) ###Wrong Vertices # Graf([,,[2,5,4]],[,[1,2],[3,4]]) # Graf([,[1,2],[3,5]],[,[1,3],[4,5]]) # Graf([,[1,5,3,2]],[,[1,2],[4,5]]) ###MULTIEDGES # Graf([,[1,2,5,3]],[,[1,3],[4,5]]) ###MULTIEDGES # Graf([,[1,2,5,4]],[,,[1,4,3]]) ###MULTIEDGES # Graf([[2,5],[1,4,3]],[,[1,5],[2,3]]) ###Wrong Vertices # Graf([[1,4],[2,5,3]],[,,[1,4,5]]) ###MULTIEDGES # Graf([[3,4],[1,2,5]],[,,[1,5,3]]) ###MULTIEDGES ####### Don't come out right ##Graf([,[1,2,5,3]],[,[2,3],[4,5]]) ## Graf([[3,5],[1,4,2]],[,,[1,4,5]])
dictionary of neighboring edges: {0: , 1: [1, 5, 3, 2], 2: , 3: [1, 2], 4: [4, 5]} verts before flipped order: {0: , 1: [3, 4, 2], 2: , 3: , 4: [0, 1]} verts after flipped order: {0: , 1: [2, 4, 3], 2: , 3: , 4: [1, 0]}
Error in lines 48-48 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags), namespace, locals) File "", line 1, in <module> File "", line 45, in Graf File "/ext/sage/sage-8.8_1804/local/lib/python2.7/site-packages/sage/graphs/generic_graph.py", line 2444, in set_embedding self._check_embedding_validity(embedding, boolean=False) File "/ext/sage/sage-8.8_1804/local/lib/python2.7/site-packages/sage/graphs/generic_graph.py", line 2542, in _check_embedding_validity raise ValueError("the list associated with vertex {} has length {} but d({})={}".format(v, len(embedding[v]), v, self.degree(v))) ValueError: the list associated with vertex 1 has length 3 but d(1)=4