This program utilises dijkstra's algorithm to calculate the fastest path between two stations that were given by the user. It utilises the tube station data set from the Freedom of Information request found. here (can be downloaded directly via this link).
cd into the main directory & use gcc to compile the code. The executable should appear in the main directory.
$ cd tfl_project-main
$ gcc -o tfl src/main.c
the executable expects a relative path to the station's database, which is "data/stations_db.csv". If it doesn't exist, it'll print an error and exit. Run the executable.
$ tfl.exe
(1) Finds the fastest path between two stations. It will ask for a starting station name & a target station name.
(2) Outputs the names of the stations starting with a certain character. It will ask for a character to find the required stations.
(3) Adjust line switch time, which is the time given if the user needs to switch lines. It will ask for a value between 0 and 30 inclusive.
(4) Exit the program.
Firstly, the dataset has been manipulated by:
- Sorting the rows in alphabetical order (A → Z) based on the Station From (A) column, as well as deleting the first row.
- Ensuring that stations fall under the same name even if they are the same station. e.g. Euston (CX) → Euston.
- Ensuring that stations don't have a space after their name. e.g. "Baker Street " → "Baker Street".
- Deleting the "AM Peak" & "Inter Peak" Columns.
- Converting the file into a .csv to allow the file to be read more easily.
References: Dijkstra's Algorithm - Computerphile