Back to Freecodecamp

Step 25

curriculum/challenges/english/blocks/learn-algorithm-design-by-building-a-shortest-path-algorithm/655773f8b8b5db9fc6d0ae76.md

latest975 B
Original Source

--description--

To keep track of the visited nodes, you need a list of all the nodes in the graph. Once a node is visited, it will be removed from that list.

Now, replace the pass keyword with a variable named unvisited and assign it an empty list.

--hints--

You should have a variable called unvisited inside the shortest_path function.

js
({ test: () => assert(runPython(`_Node(_code).find_function("shortest_path").has_variable("unvisited")`)) })

You should assign an empty list to your unvisited variable. Remember to delete pass.

js
({ test: () => assert(runPython(`_Node(_code).find_function("shortest_path").find_body().is_equivalent("unvisited = []")`)) })

--seed--

--seed-contents--

py
--fcc-editable-region--
my_graph = {
    'A': [('B', 3), ('D', 1)],
    'B': [('A', 3), ('C', 4)],
    'C': [('B', 4), ('D', 7)],
    'D': [('A', 1), ('C', 7)]
}

def shortest_path(graph, start):
    pass
--fcc-editable-region--