Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I have an assaignment from Data Structures and Algorithms. The question should be solved with Java and using graph structure. The input is written below
I have an assaignment from Data Structures and Algorithms. The question should be solved with Java and using graph structure. The input is written below of first paragraph. I will attach the image of the assaignment. You have a map of Turkey, and you want to start from one city and finish your trip
in another city. However, there may be cities you want to visit during this trip.
Therefore, you have to visit these cities as well. In this question, your task is to
find the shortest route from your starting city to your ending city. This route should
also include the cities you want to visit. You should read Turkey map from the txt
files which shown in following image:
Eskisehir, Ankara,
Eskisehir, Bolu,
Eskisehir, Bilecik,
Eskisehir, Kutahya,
Eskisehir, Afyonkarahisar,
Eskisehir, Cankiri,
Eskisehir, Kastamonu,
Cankiri, Kastamonu,
Ankara, Istanbul,
Istanbul, Cankiri,
Kastamonu, Corum,
Corum, Amasya,
Amasya, Tokat,
You should read this file line by line and construct an undirected graph with
given weight. For example, the first line means that there is a path between
Eskisehir and Ankara with length of
To find a shortest path, first you should read source city, destination city and
number of cities which you want to visit, and name of these cities from the
console, respectively. If there is more than one city to visit, you should visit them
based on console order. For example, you read cities to visit from the console as A
B C Then, you should keep this order during your trip and first visit Athen B then
Example inputsoutputs are as follow: input.txt you should read input txt file from the user
Eskisehir source city
Kastamonu destination city
number of city you want to visit
Routes are:
EskisehirKastamonu
Length of route is: input.txt you should read input txt file from the user
Eskisehir source city
Kastamonu destination city
number of city you want to visit
Cankiri City to visit
Routes are:
EskisehirCankiriKastamonu
Length of route is:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started