Question: You are given a directed graph G = ( V , E ) with non - negative edge weights w ( u , v )
You are given a directed graph with nonnegative edge weights representing
the time it takes to go from a node to when and are directly connected. We assume all
for simplicity. Some subset of vertices in are pharmacies, while some other
subset are doctor offices. You live at a node and have a medical emergency. You now need to
go to some doctor office dinD to get a prescription for the drug, then to some pharmacy finF,
and finally back home. Recall that a proper output must be the full path described above. However
some paths are better then others. Solve the following variants of this problem, where each variant
describes how to compare different valid paths when choosing the optimal path you are looking for.
Each variant could be solved by one "clever" run of the Dijkstra's algorithm, on an appropriate
modification of our graph You have to explain your choice and state the resulting running time
as the function of remember we assume here, as
a points Assume only the distance from your home to the doctor's office matters eg
you need to get doctor's emergency help asap, and the time it then takes to the pharmacy
and back home are not important
b points Assume only the distance between the doctor office and the pharmacy matters.
Eg the doctor would perform some painful procedure, but does not have a tranquilizer to
numb the subsequent pain. Thus, you must choose an office dinD and pharmacy finF with
the smallest distance between them, but do not care how far is from or is from Eg
if there is a pharmacy in some doctor's office in Antarctica, you do not mind going there, as
the answer you care will be even if you live in NYC
Hint: Add an artificial source node to and compute the distance from to "fill the
blank" in your new graph.
c points Assume only the distance from the pharmacy back to home matters. Eg
the medicine must be administered by the pharmacist and has some quick side effect, so you
must get to bed asap after taking the medicine in the pharmacy.
Hint: Two solutions are possible: one does something to the edges of and the other again
adds some artificial source similar to part b
d points Finally, assume that the overall trip time from to to to matters. Show how
to combine the ideas in parts ac to solve this variant.
Hint: Make several "copies" of and connect them "appropriately" by weight edges.
The copies will ensure that every valid path must pass through a doctor office followed by a
pharmacy.
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
