# 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:
for l in left:
for r in rt:
BipartiteGraph(G).to_directed().plot()

edit retag close merge delete

Sort by » oldest newest most voted Just a slight modification of your code. Not sure if this is what you are looking for.

G = DiGraph() # G=Graph(); Use DiGraph instead. (-ppurka)
left=['S1','S2','S3']
rt=['T1','T2','T3','T4']
pre_pos=graphs.CompleteBipartiteGraph(len(left),len(rt)).get_pos()
pos={}
for (i,v) in enumerate(left+rt):
pos[v]=pre_pos[i]
for l in left:
for r in rt:
G.plot(pos=pos) # G.to_directed().plot(pos=pos); Graph is already directed (-ppurka)


Sample output (new sample output -ppurka): more

This is close to what I was aiming for. Thank you! Is there a way to only have edges coming out of the S vertices and going into the T vertices?

Updated the first and last line of @fidbc's code. Nice idea there, fidbc.