Given a weighted graph represented as an adjacency list, find the minimum cost path from a specified source node to all other nodes in the graph.
Explanation: The minimum cost path from node 'A' to node 'B' is A -> B with a cost of 5. The minimum cost path from node 'A' to node 'C' is A -> C with a cost of 2. The minimum cost path from node 'A' to node 'D' is A -> C -> D with a cost of 5.
Explanation: The minimum cost path from node 'E' to node 'F' is E -> F with a cost of 1. The minimum cost path from node 'E' to node 'G' is E -> G with a cost of 3. The path E -> F -> G has a cost of 5, but the direct path E -> G is indeed cheaper.
Shortest path in weighted graph
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak