Using NetworkX "all_pairs_dijkstra_path" function, it is possible to find all-pairs shortest paths in a graph G. Now, assume, the graph G is so large, say includes 100,000 nodes, and I am only interested in finding the shortest paths for a subset of the nodes, say 1,000 randomly drawn nodes.
Using the "dijkstra_path" function of NetworkX, I can loop over the subset of nodes and find what I am looking for. However, doing so does not seem to be efficient as I would be calling the function n times (assuming the length of the subset is n) and the so far investigated information would be discarded. I read multiple posts mentioning that all_pairs functions are better for searching paths between all pairs rather than using single source-to-target functions in a loop. Is there a way to provide a subset of nodes as an input in NetworkX? Or what is the next best approach?
The question is a duplicate of this unanswered question.