Back to Freecodecamp

Step 24

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

latest798 B
Original Source

--description--

The algorithm will start at a specified node. Then it will explore the graph to find the shortest path between the starting node, or source, and all the other nodes.

For that your function needs two parameters: graph, and start. Add them to your function declaration.

--hints--

Your function should take graph and start as the parameters, in this order.

js
({ test: () => assert(runPython(`
    import inspect
    sig = str(inspect.signature(shortest_path))
    sig == '(graph, start)'
  `))
})

--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():
    pass
--fcc-editable-region--