I have found a solution that was posted some times ago and I have tried to apply it to my exercise but it doesn\'t work. I have a class graph that has nodes and edges and a
Since you only want to get all paths from start to end, the path is appended to your total path list when it reaches the end. The total list of paths is not returned but rather populated:
paths = []
def myDFS(graph,start,end,path=[]):
path=path+[start]
if start==end:
paths.append(path)
for node in graph.childrenOf(start):
if node not in path:
myDFS(graph,node,end,path)