Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question should be solved using graph data structure in java. I would be grateful if you pay attention to the requirements asked by the

This question should be solved using graph data structure in java. I would be grateful if you pay attention to the requirements asked by the question.

Thank you for your effort.

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:

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

------------------------

input.txt // you should read input txt file from the user

Eskisehir // source city

Kastamonu //destination city

2 // number of city you want to visit

Ankara // first City to visit

Cankiri // second City to visit

Routes are: Eskisehir-Ankara-Istanbul-Cankiri-Kastamonu

Length of route is: 66

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

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions