#!/usr/bin/env python import collections graph = {'A': ['B', 'C'], 'B': ['C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F'], 'F': ['C']} #Using DFS algorithm #Ref - https://www.python.org/doc/essays/graphs/ def find_all_paths_dfs(graph, start, end, path = []): path = path + [start] #Reachd end return path if start == end: return [path] #No path found found if not graph.has_key(start): return [] paths = [] for node in graph[start]: if node not in path: new_paths = find_all_paths_dfs(graph, node, end, path) for new...
Happy learning.