Dijkstra's Algorithm is used here to solve a Single-Destination Shortest Path problem to get the shortest path from all vertices in a graph to a given vertex.
Done as part of the Design and Analysis of Algorithms Course (UE19CS251) at PES University, Bangalore.
The first line of the input file contains the number of vertices in the graph.
The subsequent lines consist of: {Node} {vertex, weight of connection to vertex} where the pair of {vertex, weight} can be repeated for every other vertex in the graph.
The last vertex (the highest numbered vertex) is taken as the Destination.
Sample Input File
Each line of the output corresponds to: {Node} {Vertices in the path (including Node and Destination)} {Path Length}
In case there is no path, "NO PATH" is printed
Clone this repository and run using the following command: make -f makefile.mk
Input file can be changed in line 57 in server.c
fp = fopen("file_name.txt", "r");
Note 1: To use the make
command in windows, use Windows Subsystem for Linux
Note 2: Uncomment the display
function in client.c
to see the graph that has been constructed.