I have a dictionary with the following structure:
KEY VALUES
v1 = {v2, v3}
v2 = {v1}
v3 = {v1, v5}
v4 = {v10}
v5 = {v3, v6}
The values of a key are actually links to other keys. By using the values I want to reach the other keys till the end. Some keys are not linked as you can see for v4. I think this is similar to graph traversal?
starting from v1
I want to travel to all the other values:
v1 --> v2 --> v1
--> v3 --> v1
--> v5 --> v3
--> v6
v4 --> v10
def travel():
travel_dict = defaultdict(list)
travel_dict[v1].append(v2)
travel_dict[v1].append(v3)
travel_dict[v2].append(v1)
travel_dict[v3].append(v1)
travel_dict[v3].append(v5)
travel_dict[v5].append(v3)
travel_dict[v5].append(v6)
travel_dict[v6].append(v5)
travel_dict[v4].append(v10)
What Recursive function can I use to travel the dictionary?