How to count face on a bipartite graph?

asked 2019-07-04 06:18:28 +0200

CamDTho3 gravatar image

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 Thanks for your time, Cameron Thomas

graph=Graph(D, multiedges=True)
def Dessin(S0, S1):
    numVertices = len(S0)+len(S1)
    #adds keys to G
    for i in range(numVertices):
    for i in range(len(S0)):
        for j in range(len(S0[i])):
            for k in range(len(S1)):
                if S0[i][j] in S1[k]:
                    graph.add_edge(i,k + len(S0),S0[i][j])
def color(S0, S1):
    for i in range(len(S0)):
    for i in range(len(S1)):
    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()


edit retag flag offensive close merge delete


What about using

sage: RibbonGraph?
FrédéricC gravatar imageFrédéricC ( 2019-07-05 09:49:58 +0200 )edit