So I would like to make this program read a user inputted matrix instead of the one that is provided in the main function. Also, the limit to the 2d matrix should be more than 9, but no more than about 100 and should also be user defined.
The main function purpose that I had in mind would be something like:
printf("Enter number of towns: ");
printf("Enter distance matrix");
which is giving me a great headache trying to write.. Any help would be greatly appreciated. Thank you.
// A C / C++ program for Dijkstra's single source shortest path algorithm.
// The program is for adjacency matrix representation of the graph
// 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;
// A utility function to print the constructed distance array
int printSolution(int dist, int n)
printf("Vertex Distance from Source\n");
for (int i = 0; i < V; i++)
printf("%d \t\t %d\n", i, dist[i]);
// Funtion that