Menu

NetworkX shortest path

Reddit r/learnpython·u/CraftingtableCat·7 months ago
#JGf9d6tn
#networkx#shortest#path#graph#need
Reading 0:00
15s threshold

I have a very large graph: an OSM network for an entire country. I need to run thousands of origin-destination shortest-path queries over this network, but the workflow is currently very slow.

I would like to parallelize the process, but "networkx.shortest_path" only accepts one OD pair at a time.

The obvious options do not seem workable:

Batching OD pairs and running multiple graph copies in parallel is not feasible because the graph is too large and memory becomes the bottleneck.

Using a single-source shortest-path approach with cached results is also not very useful, because repeated origin nodes are rare in my OD set.

I looked into NetworkX backends and came across cuGraph. My understanding is that even if the computation runs on the GPU, I would still need to submit each OD query sequentially from NetworkX. Is that correct?

It feels surprising that running many shortest-path queries on the same graph in parallel is not directly supported.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.