I am trying to plot numbers of a problem "Collatz Conjecture" which forms a nice network between numbers(node labels). However, in the final plot of the solution using networkx nx.spring_layout(G)
I get overlapping edges and nodes:
The nx.spring_layout is configured(through trial and error) as:
pos=nx.spring_layout(G,k = 0.004, iterations = 500, scale = 0.6)
nx.draw(G, labels=labels, pos=pos, font_size = 6, alpha = 0.5, node_size = nodes.values())
plt.show()
Is there a particular way to prevent this overlap, given that there is adequate empty space in the plotting window? Node size in this case is dictated by the value of:len(G.neighbors(node))
No node has more that 3 neighbours and the max node size is capped at 300 to further prevent overlap.
The odd thing is that for the longer branches this seems to be handled fairly well, but for branches such as [24,12,6,3,10] as in the images, it fails to demarcate this branch sufficiently, in other cases it overlaps altogether. Please advise if I should use another layout besides nx.spring_layout(G)
which might handle this better.