Search code examples
python-2.7graphnetworkxgraph-tool

Find k shortest paths with graph-tool


I have a directed graph for which I am trying to find the top k shortest paths. At the moment I have implemented the network in graph-tool which provides a shortest path algorithm but no k shortest paths algorithm by what I can tell. I have come across this post (All shortest paths using graph_tool) but I am not after all paths connecting two nodes.

It seems as if NetworkX has a function implemented for this (https://networkx.readthedocs.org/en/stable/reference/generated/networkx.algorithms.shortest_paths.generic.all_shortest_paths.html?highlight=all_shortest_paths). Is there a way to somehow do this in graph-tool too or am I better off switching toolboxes and using NetworkX?


Solution

  • This is available in the git version: https://graph-tool.skewed.de/static/doc/dev/topology.html#graph_tool.topology.all_shortest_paths