This application is written in C# .NET v4.5.2 and it's used to calculate distances and routes within a rail network (graph database).
-
Docker. Please make sure the Docker daemon is running before you continue.
-
Make (Don't worry if you don't have make installed, all the commands are wrapper in
Makefilewithin the source code). OpenMakefileto view the commands.
-
The data or rail network map consists of routes:
[StationFrom][StationTo][DistanceBetween], egAB5 -
Each route must be comma seperated
AB5, BC4 -
The station names must only be one alpha-character
[a-zA-Z] -
The distance may be of any integer size greater than ZERO
-
The application treats the unit of distance as miles. This is to help prevent connascence of meaning. I.e. to prevent the coupling between the application knowing that an
intrepresents some unit of distance
-
Unzip the contents of TrainsCSharpCR
-
Open up your preferred terminal and browse to TrainsCSharpCR
-
Build the docker container and run the tests:
make -
You can then run the executable,
Trains.App.exewith the following syntax:docker run trains mono Trains.App.exe [FILEPATH] [COMMAND] [QUERY]###NB. the filepath, in the above command, is relative to the entry point within the Docker container. Dockerfile adds everything within TrainsCSharpCR to /src, therefore Graph.txt can be located within the Docker container at /src/data/Graph.txt###
For example, to find the distance of the route A-B-C:
docker run trains mono Trains.App.exe /src/data/Graph.txt -d ABC(copy this exact command)If you need to bring up the help menu:
docker run trains mono Trains.App.exe -h###
docker run trainswill open and run the Docker container tagged 'trains'###
If you want to add another data file, simply place the file into the data folder, build and run the container again. You can then point the application to that file by specifying the path in the command line
There are 6 commands:
-
-dDistance between given stopsdocker run trains mono Trains.App.exe [FILEPATH] -d ABC -
-hHelp menudocker run trains mono Trains.App.exe -h -
-sLength of the shortest route between two given stopsdocker run trains mono Trains.App.exe [FILEPATH] -s AC -
-nNumber of different routes between two given stops under a certain distancedocker run trains mono Trains.App.exe [FILEPATH] -n CC30 -
-teExact number of trips between two given stopsdocker run trains mono Trains.App.exe [FILEPATH] -te AC4 -
-tmMax number of trips between two given stopsdocker run trains mono Trains.App.exe [FILEPATH] -tm CC3
The application exits immediately after displaying the result.
The queries vary depending on which command you choose:
-
-dThis needs to display the entire route and have a minimum of two stationsABorABCDE -
-sThis must contain only two stationsACorBD -
-nThis must contain two stations and an integer representing the maximum distance between the two stationsCC30orAE20 -
-teThis must contain two stations and an integer representing the exact number of trips between the two stationsAC4orBD10 -
-tmThis must contain two stations and an integer representing the maximum number of trips between the two stationsCC3orCE15