Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java language Design and implement a program to read information about roads connecting a set of cities and find the shortest path between two

In java language

Design and implement a program to read information about roads connecting a set of cities and find the shortest path between two cities entered by the user.

Input File:

Input consists of information about the roads connecting the set of cities. The first line of input contains 2 integer M and N where indicated the number of cities and M the number of roads. The next M lines contain the description of the roads. Each road is described by 3 numbers S, D, L, where S and D are cities numbers and L is the distance between them.

Output:

A line containing the shortest distance to go from city S to D.

Sample input:

5 10

0 1 16

0 3 2

0 4 3.0

1 2 5

2 1 3

3 1 12

3 4 7

4 1 10

4 2 4

4 3 5

Sample output

The shortest distance between 0 and 1 is 10

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

Question

7. Where Do We Begin?

Answered: 1 week ago