Answered step by step
Verified Expert Solution
Link Copied!

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, 10
Eskisehir, Bolu, 20
Eskisehir, Bilecik, 5
Eskisehir, Kutahya, 30
Eskisehir, Afyonkarahisar, 50
Eskisehir, Cankiri, 10
Eskisehir, Kastamonu, 5
Cankiri, Kastamonu, 12
Ankara, Istanbul, 14
Istanbul, Cankiri, 30
Kastamonu, Corum, 14
Corum, Amasya, 14
Amasya, Tokat, 12
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 10.
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 A,then B, then C.
Example inputs/outputs are as follow: input.txt // you should read input txt file from the user
Eskisehir // source city
Kastamonu //destination city
0// number of city you want to visit
Routes are:
Eskisehir-Kastamonu
Length of route is: 5 input.txt // you should read input txt file from the user
Eskisehir // source city
Kastamonu //destination city
1// number of city you want to visit
Cankiri // City to visit
Routes are:
Eskisehir-Cankiri-Kastamonu
Length of route is: 22
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions