Question: A text file describing the graph in Fig. 1 is given below: 5 1, 10 8, 10 10,8 7,4 3,1 0,1,10 1,2,5 2,3,25 0,3,3
A text file describing the graph in Fig. 1 is given below: 5 1, 10 8, 10 10,8 7,4 3,1 0,1,10 1,2,5 2,3,25 0,3,3 3,4,8 VO V4 10 V3 VI S Figure 1: Example of a weighted undirected graph. Write a program with the following requirements: 1. Your program should read the information of a weighted undirected graph G = (V, E) using a text file in the following format: (a) The first line has an integer specifying the number of vertices in the graph (i.e., IVI). (b) Lines from line number 2 to line number |V|+1 give the x- and y- coordinates of all vertices starting from vo. These lines are in the format of two integers separated by a comma. (c) Lines from line number |V+2 to the last line give information about the edges of the graph in the format of three integers separated by commas. A line containing i, j, k tells you that there is an edge between v; and v; and its weight is k. Vertices are numbered from 0 to [V - 1, where |VI is given to you in the first line of the text file. 2. Your program should draw the Graph described in the text file. 3. Your program should find and highlight the shortest path between two vertices entered by the user. Note that the user will enter two integers representing the vertices he/she is asking about and your program will highlight (with a different color) the shortest path between them.
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
It appears youve uploaded two images I see that one contains a graph and the o... View full answer
Get step-by-step solutions from verified subject matter experts
