I have a problem where I have a graph (representing an electrical network), a list of the source nodes and a list of the drain nodes.
for every drain node, I need to find all the possible paths to every source node.
The trivial solution is:
def get_all_paths(graph, start_list, end_list):
import progressbar
progress = progressbar.ProgressBar()
results = dict()
for end in progress(end_list):
paths = list()
for start in start_list:
paths.append(find_all_paths(graph, start, end))
results[end] = paths
return results
The routine find_all_paths
can be found here.
The question is: What can I do to speed up the function find_all_paths
? It feels like much information is thrown away when the routine find_all_paths ends and is called again.