Below is a weighted undirected graph:
Find all the shortest paths from the node to all other nodes of the graph using Dijkstra's algorithm. As an answer, print edges of the shortest path tree. Edges' order does not matter. The last line of your answer should contain the shortest distance from to every node of a graph (nodes are sorted in alphabetical order, the shortest distance from to is 0).
Below is an example that clarifies the expected output format:
A B
B C
C D
0 2 3 5
Here, the first three lines correspond to three edges of the shortest path tree (an edge from to , an edge from to , and an edge from to ), while the last line corresponds to the shortest distance from the starting node to every node of a graph. The starting node is , the shortest distance from to is 0, from to – 2, from to – 3, from to – 5.