0
Check if the path is exist or not in the graph
def dfs(graph,start,end): if start == end : return True for i in graph[start]: if dfs(graph,i,end) == True: return True return False graph = {'2': set(['7','9']), '5': set(), '7': set(['2']), '9': set(['2'])} print(dfs(graph,'7','9')) Please help me by correct this code.
1 Resposta
+ 1
Pass memo also in
if dfs(graph,i,end,memo) == True: