Recursive graph traversal: how to generate and return all paths?
问题 Here is my code right now: hasht= {"A":["B", "D", "E"], "B":["C"], "C":["D", "E"], "D":["C", "E"], "E":["B"]} paths=[] def recusive(start, finish, val): if start==finish and val!=1: return start else: for i in hasht[start]: path= start+ recusive(i,finish,2) paths.append(path) print (recusive("C","C",1)) print paths Desired output: [CDC, CDEBC, CEBC] I am trying to generate a table like the one above, but I am running into a problem where the string and the array are not being concatenated.