1 def find_all_paths(graph, start, end, path=[]):
2 path = path + [start]
3 if start == end:
4 return [path]
5 if not graph.has_key(start):
6 return []
7 paths = []
8 for node in graph[start]:
9 if node not in path:
10 newpaths = find_all_paths(graph, node, end, path)
11 for newpath in newpaths:
12 paths.append(newpath)
13 return paths
14