ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 04 Jul 2019 06:18:28 +0200How to count face on a bipartite graph?https://ask.sagemath.org/question/47057/how-to-count-face-on-a-bipartite-graph/I am graphing a bipartite graph but I need to rearrange the graph. The graph is generated by a list of list. One of the rearrangement guidelines is that the faces have to be surrounded by a certain amount of "white" vertices. Therefore, I wanted to create a checker function that can count the faces of the graph and count the "white" vertices around that face. If the graph doesn't have the correct amount of faces and/or the number of "white" vertices then the program will rearrange the graph. I would like some guidance on this task, what code/math I should use or if I should use a different approach. I have attached the code. If more information is needed to help, please contact me at cameron.dthomas@morehouse.edu
Thanks for your time,
Cameron Thomas
D={}
graph=Graph(D, multiedges=True)
def Dessin(S0, S1):
numVertices = len(S0)+len(S1)
G={}
#adds keys to G
for i in range(numVertices):
G[i]=(S0+S1)[i]
for i in range(len(S0)):
#print(S0[i])
for j in range(len(S0[i])):
#print(S0[i][j])
for k in range(len(S1)):
if S0[i][j] in S1[k]:
graph.add_edge(i,k + len(S0),S0[i][j])
print(G)
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]
Dessin(S0, S1)
color(S0, S1)
graph.graphplot(edge_labels=True, vertex_colors={'grey': color(S0,S1)[0],'white':color(S0,S1)[1]}, vertex_labels=True).show()
return(graph)
Graf([[1,5,4,3,2]],[[1],[2],[3],[4],[5]])CamDTho3Thu, 04 Jul 2019 06:18:28 +0200https://ask.sagemath.org/question/47057/checking isomorphism for weighted bipartite graphhttps://ask.sagemath.org/question/26130/checking-isomorphism-for-weighted-bipartite-graph/Hi, guys,
I am working on a problem involving checking if two weighted bipartite graphs are isomorphic.
I saw I can define a weighted graph in sage like this:
sage: X = Matrix([(0,0,1,1),(0,0,1,2),(0,1,1,0)])
sage: XX = BipartiteGraph(X,weighted=True)
sage: Y = Matrix([(1,0,2,0),(1,0,0,1),(1,0,1,0)])
sage: YY = BipartiteGraph(Y,weighted=True)
sage: W = Matrix([(1,0,2,0),(1,0,0,1),(1,0,2,0)])
sage: WW = BipartiteGraph(Z,weighted=True)
I swapped rows and columns of matrix defining X to get Y, so Y is isomorphic to X,
But since my graphs are weighted, I changed one element in Y from 1 to 2 to get W,
yet it still tell me XX and WW are isomorphic
sage: YY.is_isomorphic(XX)
True
sage: ZZ.is_isomorphic(XX)
True
Are there other functions I can use to check isomorphism for weighted bipartite graph?skylibraryTue, 10 Mar 2015 07:13:07 +0100https://ask.sagemath.org/question/26130/