A text file describing the graph in Fig. 1 is given below: 5 1, 10 8,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
It appears that you have a twopart task requiring you to write a program based on requirements regarding the representation and manipulation of a weighted undirected graph 1 Read the graphs informatio... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-7. Ivan sold the following securities during the year and received a Form 1099-B that...
-
The following list of balances has been extracted from the records of company cowgale co as of 31 October 2017 the end of the most recent financial year. Notes 1. The balance on the corporation tax...
-
In a clinical study, volunteers are tested for a gene that has been found to increase the risk for a disease. The probability that a person carries the gene is 0.1. (a) What is the probability 4 or...
-
True or false? Explain. a. x x = Rumpelstiltskin is a valid (necessarily true) sentence of first-order logic. b. Every existentially quantified sentence in first-order logic is true in any model...
-
The body mass index (BMI) adjusts your weight for your height. You can calculate your BMI as follows: What does BMI mean? BMI tells you if you are underweight or overweight. Note, however, that BMI...
-
Melissa Mertz purchased a used tractor for $17,500. Before the tractor could be used, it required new tires, which cost $1,100, and an overhaul, which cost $1,400. Its first tank of fuel cost $75....
-
In 2026, Blossom Corporation has an actual return on plan assets of $151000. The expected rate of return is 10%. The fair value of plan assets on January 1, 2026 was $1020000, and the fair value of...
-
V. N. Murti and V. K. Sastri investigated the production characteristics of various Indian industries, including cotton and sugar. They specified CobbDouglas production functions for output (Q) as a...
-
7) You are considering the purchase of ABC Co. You expect that ABC Co. can generate cash flows of $34,000, $45,000, and $56,000 over the next three years, respectively. After that time, the business...
-
Sven starts walking due south at 6 feet per second from a point 110 feet north of an intersection. At the same time Rudyard starts walking due east at 5 feet per second from a point 150 feet west of...
-
The list price for a vacuum cleaner is $299.99. Determine the net cost after a 15/10/10 series discount $417.44 $299.64 $206.54 $100.20 0000
-
Suppose that you purchase a 25 year, 10% per annum coupon rate bond when its yield to maturity is 7% per annum compounded semi-annually. Par value is $10,000. Coupons are paid every six months and...
-
3. A 2.39mg sample of safrole, a non-electrolyte solute, was dissolved in 103.0 mg of diphenyl ether. The solution had a melting point of 25.70 C. Calculate the molecular mass of safrole. The...
-
Rachel, aged 40, and Simon Sweeny, aged 42, have recently finished building their 4-bedroom and 2-bathroom house.Their house is valued at $1,000,000, belongings are valued at $250,000 and they have a...
-
2. A line has equation y=r-0.5 a. Pick five distinct x-values, use the equation to compute the corresponding y-values, and plot the five points obtained. b. Give the value of the slope of the line;...
-
In a large midwestern university, 30% of the students live in apartments. If 200 students are randomly selected, find the probability that the number of them living in apartments will be between 55...
-
Bea Jones (age 32) moved from Texas to Florida in December 2011. She lives at 654 Ocean Way, Gulfport, FL 33707. Bea's Social Security number is 466-78-7359 and she is single. Her earnings and income...
-
Rebecca and Walter Bunge have been married for 5 years. They live at 883 Scrub Brush Street, Apt. 52B, Las Vegas, NV 89125. Rebecca is a homemaker and Walt is a high school teacher. Rebecca's Social...
-
Indicate, in each of the following situations, the number of exemptions the taxpayers are entitled to claim on their 2012 income tax returns. Number of Exemptions a. Donna, a 20-year-old single...
-
Which blood vessels are responsible for nutrient and waste exchange with tissues?
-
What are the three types of blood cells, and what is the function of each?
-
Trace the path of air as it moves to the alveoli.
Study smarter with the SolutionInn App