0

I have 2 list of nodes A and B for graph G in networkx.

I want to draw the nodes such that List A remains on left side and nodes in List B on right side.

For this I want to know the size of the window and do something like for nodes in List A have spring layout on the left side of window and the same for List B on right side.

Is there any way to do so.... ?

import matplotlib.pyplot as plt
import networkx as nx
g = nx.Graph()
ListA = [1]
ListB = [2]
for node in ListA:
    g.add_node(node)
for node in ListB:
    g.add_node(node)
pos=nx.spring_layout(g)   // want to change the position of all the nodes such that ListA is on left and ListB is on right
print pos
nx.draw_networkx_nodes(g,pos,nodelist=ListA,node_color='r')
nx.draw_networkx_nodes(g,pos,nodelist=ListB,node_color='g')
nx.draw_networkx_labels(g,pos)
plt.show()

1 Answer 1

0

This link draws the graphs seperately, but I'm not sure it draws them in any particular orientation.

http://networkx.lanl.gov/examples/drawing/atlas.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.