thesuhas / Dijkstra-in-C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dijkstra-in-C

GitHub forks GitHub stars Github license

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.

Input Format

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

Output Format

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

How to Use

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.

About

License:MIT License


Languages

Language:C 98.8%Language:Makefile 1.2%