Efficiently calculate distances in a graph up to a certain limit
I’m trying to calculate the distances (length of the shortest paths) between all pairs of nodes in a large graph (about 160k nodes). I’ve tried several implementations of this, the igraph distances()
in R
, the shortest_path_lengths()
from NetworkX in Python, and some selfmade implementations of the Dijkstra algorithm. However, this calculation takes forever (~3-4 hours on a very large machine), and I wanted to know if there is a more efficient way of doing this. Basically: What is currently the most efficient implementation of calculating all distances in a graph that you know of that I could call from R or Python?
Another hint:
One factor in my data is that the distances in my graph are either small (<10) or infinite, so I was wondering if there is a way of utilizing this to make the computation faster, i.e. to stop it after distance 10 for example? Are there implementations where I can easily add a ‘stoppage’ condition for calculating the distances?
Any help is greatly appreciated 🙂