Dijkstra's Algorithm Lists
#include <stdio.h> #include <stdlib.h> #include <limits.h> #define MAX 100 #define INF INT_MAX typedef struct Edge { int dest; int weight; struct Edge* next; } Edge; typedef struct Graph { Edge* edges[MAX]; } Graph; int dist[MAX]; int pred[MAX]; int visited[MAX]; void create_graph(Graph* graph, int n, int gtype); void dijkstra(Graph* graph, int n, int source); void print_shortest_path(int source, int destination); int main() { int n, gtype, source; printf("Enter 1 for undirected graph and -1 for directed graph: "); scanf("%d", >ype); printf("Enter the number of vertices: "); scanf("%d", &n); Graph graph = { {NULL} }; create_graph(&graph, n, gtype); printf("Enter the source vertex: "); scanf("%d", &source); dijkstr...