Question: Suppose that you are searching for an airline flight. You will be interested in the price of the flight, but you will probably also

Suppose that you are searching for an airline flight. You will be interested in the price of the flight, but you will probably also be interested in the amount of time that the flight(s) will take. This program is based on that problem. You will be given a directed graph where each edge has a cost and a duration. Your job will be to find the shortest duration path that doesnt go over a given total cost. The graph will be given as follows. The number of vertices and edges will be on the first line, followed by one edge per line. Each edge will have the two vertices, the cost and the duration, all of which will be positive integers. Note that in this graph there may be multiple edges between any two vertices Your program should take four command line arguments: the name of the file containing the graph, the start vertex, the end vertex, and the maximum total cost. The output of the program is a single integer, the duration of the cheapest path from the start vertex to the end vertex with total cost less than the limit. If no path exists with cost less than the limit, output a 0. No other output should appear. Hint: for this program, you will want to modify the Bellman-Ford algorithm. Instead of a single weight for each vertex of the graph, you will need to maintain an ordered list based on cost. Example input graph 5 7 0 130 100 0 450 125 1 2 250 50 1 2 50 150 4 2 40 100 2 3 6090 4 3 150 125 Executing project5 graph.txt 0 3 200 Should output 250 Executing project5 graph.txt 0 3 140 Should output 340 Executing project5 graph.txt 0 3 139 Should output 0 

Suppose that you are searching for an airline flight. You will be interested in the price of the flight, but you will probably also be interested in the amount of time that the flight(s) will take. This program is based on that problem. You will be given a directed graph where each edge has a cost and a duration. Your job will be to find the shortest duration path that doesn't go over a given total cost. The graph will be given as follows. The number of vertices and edges will be on the first line, followed by one edge per line. Each edge will have the two vertices, the cost and the duration, all of which will be positive integers. Note that in this graph there may be multiple edges between any two vertices. Your program should take four command line arguments: the name of the file containing the graph, the start vertex, the end vertex, and the maximum total cost. The output of the program is a single integer, the duration of the cheapest path from the start vertex to the end vertex with total cost less than the limit. If no path exists with cost less than the limit, output a 0. No other output should appear. Hint: for this program, you will want to modify the Bellman-Ford algorithm. Instead of a single weight for each vertex of the graph, you will need to maintain an ordered list based on cost. Example input graph: 57 01 30 100 04 50 125 12 250 50 12 50 150 42 40 100 23 60 90 43 150 125 Executing project5 graph.txt 0 3 200 Should output 250 Executing project5 graph.txt 0 3 140 Should output 340 Executing project5 graph.txt 0 3 139 Should output 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solution code include include include include using namespace std struct Edge int src dest costduration a structure to represent a connected directed ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

635d712210fc8_175649.pdf

180 KBs PDF File

Word file Icon

635d712210fc8_175649.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!