Bipartite graph in NetworkX for LARGE amount of nodes

Viewed 31

I am trying to create bipartite of certain nodes, for small numbers it looks perfectly fine:

Image for around 30 nodes

Unfortunately, this isn't the case for more nodes like this one:

Image for more nodes

My code for determining the position of each node looks something like this:

pos = {}
pos[SOURCE_STRING] = (0, width/2)
row = 0
for arr in left_side.keys():
    pos[str(arr).replace(" ","")]=(NODE_SIZE, row)
    row += NODE_SIZE
row = 0
for arr in right_side.keys():
    pos[str(arr).replace(" ","")]=(2*NODE_SIZE,row)
    row += NODE_SIZE
pos[SINK_STRING] = (3*NODE_SIZE, width/2)
return pos

And then I feed it to the DiGraph class:

G = nx.DiGraph()
G.add_nodes_from(nodes)
G.add_edges_from(edges, len=1)
nx.draw(G, pos=pos ,node_shape = "s", with_labels = True,node_size=NODE_SIZE)

This doesn't make much sense since they should be in the same distance from each other since NODE_SIZE is constant it doesn't change for the rest of the program.

Following this thread:

Bipartite graph in NetworkX

Didn't help me either.

Can something be done about this?

0 Answers
Related