Program 4 Daa
Program 4 Daa
Design and implement C/C++ Program to find shortest paths from a given vertex in a weighted
connected graph to other vertices using Dijkstra's algorithm.
#include <stdio.h>
#include <limits.h>
#define V 9
// A utility function to find the vertex with minimum distance value, from
int v;
return min_index;
int i;
}
// Funtion that implements Dijkstra's single source shortest path algorithm
int dist[V]; // The output array. dist[i] will hold the shortest
int i, count, v;
dist[src] = 0;
// Pick the minimum distance vertex from the set of vertices not
sptSet[u] = 1;
printSolution(dist, V);
int main() {
{0, 8, 0, 7, 0, 4, 0, 0, 2},
{0, 0, 2, 0, 0, 0, 6, 7, 0}
};
dijkstra(graph, 0);
return 0;
Output