Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Just a slight modification of your code. Not sure if this is what you are looking for.

G=Graph()
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):
    G.add_vertex(v)
    pos[v]=pre_pos[i]
for l in left:
    for r in rt:
        G.add_edge(l,r)
G.to_directed().plot(pos=pos)

Sample output: image description

click to hide/show revision 2
No.2 Revision

Just a slight modification of your code. Not sure if this is what you are looking for.

G=Graph()
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):
    G.add_vertex(v)
    pos[v]=pre_pos[i]
for l in left:
    for r in rt:
        G.add_edge(l,r)
G.to_directed().plot(pos=pos)
G.plot(pos=pos) # G.to_directed().plot(pos=pos); Graph is already directed (-ppurka)

Sample output: image descriptionoutput (new sample output -ppurka): image description