A Rust-based project that reads a list of cities from a file, allows the user to select a starting city, and calculates the shortest path through a specified number of cities using a simple nearest-neighbor algorithm.
The Image Randomizer project loads a list of cities with coordinates from a file, prompts the user to select a starting city, and calculates the shortest path through a specified number of cities using a nearest-neighbor algorithm. The result includes the order of cities visited and the total distance traveled.
- Load a list of cities from a file.
- Prompt the user to select a starting city.
- Calculate the shortest path through a specified number of cities using a nearest-neighbor algorithm.
- Display the order of cities visited and the total distance traveled.
To install and run this project, you need to have Rust installed on your machine. Follow the steps below to set up the project:
-
Clone the repository:
git clone https://github.com/sekkensn/Image-Randomizer.git cd Image-Randomizer
-
Build the project:
cargo build
-
Run the project:
cargo run
When you run the project, it will:
- Load a list of cities from
src/default_cities.txt
. - Prompt you to enter the starting city from the loaded cities.
- Prompt you to enter the number of cities to include in the path.
- Display the shortest path from the starting city through the specified number of cities and the total distance traveled.
The expected format for the default_cities.txt
file is:
CityName, x_coordinate, y_coordinate
CityName2, x_coordinate2, y_coordinate2
-
The program loads the cities from
src/default_cities.txt
. -
Prompts the user:
Enter the starting city:
-
Prompts the user to enter the number of cities:
Enter the number of cities:
-
Displays the shortest path and total distance:
Shortest path from starting city: From City Vilnius to City Berlin - Distance 1207 km From City Berlin to City Rome - Distance 1066 km ... Total Distance: 12345 km
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details. "# TSP-Rust-Implementation"