Create a program to implement the Dijkstra algorithm for finding the shortest path in a graph.
HardProblem Statement
Create a program to implement the Dijkstra algorithm for finding the shortest path in a graph.
Sample Input
Graph: { "nodes": [0, 1, 2], "edges": [[0, 1, 4], [0, 2, 1], [2, 1, 2]] }Sample Output
Vertex Distance from Source 0 0 1 4 2 1
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
using System;
using System.Collections.Generic;
class DijkstraAlgorithm
{
static void Main()
{
// Implement Dijkstra algorithm for the given graph
}
}
Input
Graph: { "nodes": [0, 1, 2], "edges": [[0, 1, 4], [0, 2, 1], [2, 1, 2]] }Expected Output
Vertex Distance from Source 0 0 1 4 2 1