3

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?

user3259201
  • 99
  • 2
  • 11
  • If it is the road network of a city then you probably have positions for the nodes (junctions) right? Why not use those? You may not "see" very much interesting with a force-directed layout of 1000000 edges. – Aric Oct 30 '14 at 02:57

2 Answers2

1

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.

Community
  • 1
  • 1
Back2Basics
  • 7,406
  • 2
  • 32
  • 45
0

As Aric said, if you know the locations, that's probably the best option.

If instead you just know distances, but don't have locations to plug in, there's some calculation you can do that will reproduce locations pretty well (up to a rotation). If you do a principal component analysis of the distances and project into 2 dimensions, it will probably do a very good job estimating the geographic locations. (It was an example I saw in a linear algebra class once)

Joel
  • 22,598
  • 6
  • 69
  • 93