Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphing a very large graph in networkx

I am attempting to draw a very large networkx graph that has approximately 5000 nodes and 100000 edges. It represents the road network of a large city. I cannot determine if the computer is hanging or if it simply just takes forever. The line of code that it seems to be hanging on is the following:

##a is my network
pos = networkx.spring_layout(a)

Is there perhaps a better method for plotting such a large network?

like image 552
user3259201 Avatar asked Jan 19 '26 09:01

user3259201


1 Answers

Here is the good news. Yes it wasn't broken, It was working and you wouldn't want to wait for it even if you could. Check out my answer to this question to see what your end result would look like. Drawing massive networkx graph: Array too big

I think the spring layout is an n^3 algorithm which would take 125,000,000,000 calculations to get the positions for your graph. The best thing for you is to choose a different layout type or plot the positions yourself.

So another alternative is pulling out the relevant points yourself using a tool called gephi.

like image 87
Back2Basics Avatar answered Jan 21 '26 02:01

Back2Basics



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!