Question: Introduction In this project, we will be implementing a revised version of Dijkstra's algorithm and using it to solve a small variation on the shortest
Introduction
In this project, we will be implementing a revised version of Dijkstra's algorithm and using it to solve
a small variation on the shortest path problem. As in the first two projects, there is very little direction
regarding how to design or structure your code. These decisions are, mostly, left to you. Make sure to
start early and to stay organized. Note that this project is a little smaller than previous projects and is
worth a total of
Submissions
a Your C solution code projectcpp for this project should be submitted on both inginious
and Canvas.
Notes
There will be more than enough time in lab to discuss these problems in small groups and I highly
encourage you to collaborate with one another outside of class. However, you must write up your
own solutions independently of one another. You also need to start with the skeleton file give on
Canvas rename it to "projectcpp Do not post solutions in any way.
The Problem
You are a software engineer at a nameless electric vehicle company working as part of a team on a tool
for helping customers plan road trips. Charging stations are not yet as widely available as gas stations
so when determining a route from the starting point to the destination, the range of the vehicle must
be considered. With summer approaching, your team is scrambling for a solution to this problem. Using
your knowledge of graphs and shortest path algorithms, propose and implement an efficient algorithm
for determining the shortest path between two cities paying attention to vehicle range and available
charging stations.
InputsOutputs
Input will come from cin.
The first line will contain four space separated integers, and is the number of nodes in the graph.
is the number of edges in the graph.
is the maximum distance in miles the vehicle can travel on a full charge.
is the range of the vehicle with its initial charge.
The second line contains a pair of integers, start and end, indicating the start and end nodes
for the trip.
The following lines contain pairs of space separated integers, and representing nodes.
is the name of a node. This will be an integer between and
is if the node has a charging station and otherwise.
The following lines each contain three space separated integers, and representing
edges.
and are edge endpoints.
is the distance in miles between nodes and
Print output to cout.
The output will have two lines.
The first line should be "Verify Path: when a suitable path exists.
The second line should be the length of the trip followed by a colon, the start state, the
sequence of charging stations visited on the trip, and the end state.
This sequence should be space separated, should start with start, and should end with
end.
This sequence should represent a shortest path given the constraints. Ties will be broken
between the paths with the same distance by the sum of the ids of the nodes along each path in
ascending order, which means the path of the smallest sum wins.
If no suitable path exists, print No suitable path from start to end exists" where start and
end are node ids.
For example, the graph below corresponds to the input:
Output in this case should be:
Verify Path:
:
Grading
pts An implementation of Dijkstra's algorithm.
pts A solution to the given problem, based on the percentage of test cases passed on
inginious.
pts A function bool verifyPathGraph vectori path, int int Initialize all the nodes; specifically, for the starting node, initialize its distance
as its fuel remaining charge as the initial charge, and its history path as
empty.
Initialize an empty vector allP aths to store the found solution paths. It is a
vector of paths
Initialize a variable mindistance as INTMAX,
While the priority queue is not empty, perform the following steps:
a Pop the top node from the priority queue.
b Get the node ID distance, fuel, and history.
c If the current distance is greater than mindistance, break the loop.
d If the node ID is equal to the end node ID add the path history to
allPaths, and update mindistance with the minimum of mindistance
and the current distance.
e
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
