So tables differ from spreadsheets (duh, but stay with me). Building a table of distances in a spreadsheet would be a matter of X rows and X columns, one each for a location. You could find the distance A->B by looking in Column B of Row A. When it comes to SQL, computers like rows much better than columns. Something to do with the linear nature of seraching and itemization or something. The end result is that MySQL does not support 5,000 columns and would rather like three columns and 25+ million rows.
The columns are Source, Destination, Number of Jumps. And there will be a row for each Source/Dest combination. (Here we can get cute and since the distance is the same in eaither direction we can keep the table half as long, as 12.5 million rows.)
I also optimized the script a bit by only using HiSec systems as starting points. There will still be routes to LoSec where these neighbor HiSec, but I gave these routes an extra 1,000 jump weight per LoSec. This should keep them out of the way. Pretty much if you see a route that is over 1,000 jumps, ignore it.
I started the script about 20 minutes ago and it has found 40,000 routes and closed 8 solar systems. The further it gets, the quicker the searches (as the return route has been calculated) so I expect it to be done in 3 weeks. Yeah, that sounds horrible but we'll see if Phil can improve it?