/TFL-c

Transport For London, Underground Tube Project to find shortest path using dijsktra.

Primary LanguageC

Transport for London Station Pathfinder


v2.0 @ 10/11/2020

TFL

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).

Moorgate to Swiss Cottage

Compiling the code

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

Compiling

Running the executable

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

Options

(1) Finds the fastest path between two stations. It will ask for a starting station name & a target station name.

Shortest Path

(2) Outputs the names of the stations starting with a certain character. It will ask for a character to find the required stations.

Displaying 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.

Changing Time

(4) Exit the program.


Dataset Manipulation:

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