random sampling of paths between nodes using all_paths
Hello!
First of all, thanks for this package. It's really fast and friendly to use.
Now to my question. I'm using graph-tool
to:
- Create a very big graph.
Then, iteratively (potentially many many times):
- Choose two nodes on the graph (based on some logic irrelevant to the question).
- Sample paths between those two nodes using the
all_paths
function.
And everything works as expected.
The thing is, sometimes there are many paths (tens of millions, probably a lot more). Since the function returns a generator, one can go through it and sample itelligently. But even if not storing everything in memory, it still takes very long to through all paths.
The thing is, I do not actually need all the paths. I just want to sample them without bias. My samples are usually of size 500 - 5000.
So I was wondering if:
- The depth-first algorithm that does the exploration is deterministic.
- There is a possibility to sample the paths randomly during the exploration so I could potentially only get the first
sample_size
paths returned by the generator and that's it.
Thanks!
Franco