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/Find all maximum matchings in a bipartite graph. And how to relabel edges of a bipartite graph in sage?https://ask.sagemath.org/question/42324/find-all-maximum-matchings-in-a-bipartite-graph-and-how-to-relabel-edges-of-a-bipartite-graph-in-sage/ I want to find all the maximum matchings in a bipartite graph using sage, an algorithm is given in "Finding all maximally-matchable edges in a bipartite graph " by Tamir Tassa.
Also, I want to relabel the edges of my bipartite graph from 0,1,2,.. to y_1, y_2, x_1,.. ,x_1 (dot),...Rupesh KastureSun, 13 May 2018 13:31:12 +0200https://ask.sagemath.org/question/42324/Check SDR in a bipartite graph by Hall's theorem.https://ask.sagemath.org/question/31379/check-sdr-in-a-bipartite-graph-by-halls-theorem/How can I check existence of a complete SDR in a bipartite graph ?
This will be done by checking if there is a perfect matching in the graph(Hall's marriage theorem), but How can I implement this in SAGE?
vicariousMon, 07 Dec 2015 17:39:04 +0100https://ask.sagemath.org/question/31379/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/plot directed bipartite graphhttps://ask.sagemath.org/question/11353/plot-directed-bipartite-graph/I would like to have a plot of a directed bipartite graph. I can easily get the bipartite graph to look nice or the directed graph. But, I would like a bipartite picture with the directed edges. Here is what I've tried.
G=Graph()
left=['S1','S2','S3']
rt=['T1','T2','T3','T4']
for v in left+rt:
G.add_vertex(v)
for l in left:
for r in rt:
G.add_edge(l,r)
BipartiteGraph(G).to_directed().plot()calc314Fri, 11 Apr 2014 09:50:53 +0200https://ask.sagemath.org/question/11353/