Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

On reading S, the program stops. On reading R, the program reads in an edge weighted directed graph from file GRAPHinput.txt to build the adjacency

On reading S, the program stops.

On reading R, the program reads in an edge weighted directed graph from file GRAPHinput.txt to build the adjacency lists, and waits for the next command. The file GRAPHinput.txt is a text file. The first line of the file contains two integers n and m, which indicates the number of vertices and the number of edges on the graph, respectively. It is followed by m lines, where each line contains three integers: u, v, and w. These three integers indicate the information of an edge: there is an edge pointing from u to v, with weight w. Please note that the vertices of the graph are indexed from 1 to n (not from 0 to n 1). On reading W, the program writes the graph information to the screen, and waits for the next command. The screen output format of W is as follows: The first line should contain two integers, n and m, where n is the number of vertices and m is the number of edges. It should be followed by n lines, where each of these n lines has the following format:

u : (v1 w1) (v2 w2) ... (vx, wx)

On reading P s t, the program runs Dijkstras shortest path algorithm to compute a shortest s-t path, and prints out the shortest path information from s to t to the screen, and waits for the next command. The screen output format of P s t is as follows: There are two lines. The first line contains an integer dist, which is the length of the shortest path computed. The next line contains the indexes of all vertices along the path direction, starting from src and ending with dest, in format of: s v1 v2 ... t

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions