diff --git "a/Dijkstra\342\200\231s Shortest path Algorithm" "b/Dijkstra\342\200\231s Shortest path Algorithm" new file mode 100644 index 0000000..9432e31 --- /dev/null +++ "b/Dijkstra\342\200\231s Shortest path Algorithm" @@ -0,0 +1,94 @@ +// A C++ program for Dijkstra's single source shortest path algorithm. +// The program is for adjacency matrix representation of the graph +#include +using namespace std; +#include + +// Number of vertices in the graph +#define V 9 + +// A utility function to find the vertex with minimum distance value, from +// the set of vertices not yet included in shortest path tree +int minDistance(int dist[], bool sptSet[]) +{ + + // Initialize min value + int min = INT_MAX, min_index; + + for (int v = 0; v < V; v++) + if (sptSet[v] == false && dist[v] <= min) + min = dist[v], min_index = v; + + return min_index; +} + +// A utility function to print the constructed distance array +void printSolution(int dist[]) +{ + cout <<"Vertex \t Distance from Source" << endl; + for (int i = 0; i < V; i++) + cout << i << " \t\t"<