This is a program that looks for the shortest path between two points using Dijikstra algorithm. All the single connections should be given in the file specified by the user. If the path does not exist, the user is informed. If it does exist, the file with the shortest path and consecutive connections is created.
The program is designed to be run from the command line. The controls are defined as follows:
- dijikstra.exe - by default, program runs without the commands. In this configuration, it will look for the file "data.txt" in the same directory. If it cannot be found, you will be informed of this.
- dijikstra.exe --help - run this command to get basic information about the commands and further guidance through the messages.
- dijikstra.exe --input=location\data.txt - if you want to find the shortest path for the points defined in the file somewhere outside the current directory, specify its location and the programm will use it.
You can encounter the following messages during the program execution:
- Help message: it will show you all the other messages that can be displayed, as well as the commands that can be used by you.
- "No such file in chosen directory." - it means exactly that. The directory and the file you provided could not be found or you did not specify any and the program have not found the default file.
- "Unknown command" - you provided the command that could not be processed.
- "The edge should have positive value. Specify the correct length." accompanied by the names of the points - you gave 0 for the edge length. Provide actual value for the edge between these points.
- "Invalid edge. Specify the correct length." - you gave character for the edge length or gave a point with two part name and no edge. You can only specify the edge length here.
- "Invalid edge format." - after program request for the correct edge length you provided 0 or character instead of positive value.
- "... was provided. Specify the actual edge." - the input line was lacking/you provided too much. You should specify it again: start_point end_point distance
- "Choose the starting/ending point:" - the program could not find the start and end points in the last line of the input, so you should provide them manually.
- "No such node." - the point you provided is not in the graph.
- "There is no path." - the program did not find the connection between specified points.
- "There is a path!" - the program found the connection you asked for.
- "Failed to create file." - the file with the exact path could not be created.
The text file should consists of the lines of the following structure: start_point end_point distance between them. Always end the line with the enter. Do not use commas. If you want to specify the points between which you want to find the shortest path, write them in the following format: start_point end_point. End the line with enter as well. The nonpositive distance, lack of the distance in any other line, etc. will be expected to be corrected by the user through the command line during the execution process. Remember to write down the cities/point names consisting of more than one word with _ between them. Otherwise, you will be asked to specify the line once again. The exemplary data file is provided in the latest release for your convenience.
The shortest path between the two specified points will be automatically saved into the file "path.txt" in the directory of the program. The path will be written down connection by connection. You will also see the names of the two points in the console, as well as the overall distance between them. If there is no connection, you will be informed about it.
You can download the program here.
The actual version of the program is marked as Latest release. To download the code, click Source code (zip)
or Source code (tar.gz)
and save it on your computer. To download the executable file, click dijikstra.zip
and save it on your computer. Do not delete the help.txt file
as it stores all the instructions about commands and messages. Without it the --help command will not work. The output file storing the path will be created in the same folder as saved .exe
file. Remember to prepare the datafile as marked in The data file.