Find best paths sorted by length with graph tools

Good day,

I can give some feedback on this since I've also used graph-tool for
getting paths. In my case it was slightly different because (1) I wanted to
sample paths without bias, (2) I used a weight on the arcs, (3) my arcs
were directed and (4) the number of nodes and edges was really big . Sadly,
(1) and (2) made it not very easy to do it via graph tool.

As far as I understand, graph tool uses a DFS to obtain `all_paths`. When
the number of potential paths is large for a given cutoff but the remaining
number of valid paths is small, it will iterate a long time (at each
`next()`) until it proves there are no more paths that have a length equal
or smaller to the cutoff.

You could choose to stop the iteration once it starts taking longer than
certain time to find a path, but even this is no guarantee. There may be
many paths still remaining to be found. You can also play with the number
of paths to return...

Another thing you should take into account if you want to stop `all_paths`
at a limit number of paths is that since it does a DFS, two paths that are
close in the returned list will be "close" in structure (i.e., similar). So
"sampling" paths this way is not great.

Sorry I cannot be of more help. If you find a better way to do it with
graph-tool, please share it over here!

Good luck!


attachment.html (5.57 KB)