Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (a) Find the shortest weighted path from C to all other vertices in graph 2 using Dijkstra's algorithm. List both the nodes on each

1. (a) Find the shortest weighted path from C to all other vertices in graph 2 using Dijkstra's algorithm. List both the nodes on each path and the cost of each path. (b) Specify what the dist field for each node is immediately after node D has been selected off of the priority queue (but not processed). 2. Show how to modify Dijkstra's algorithm to count the number of minimum costs paths from the source vertex s to all other vertices. 3. One idea to find minimum cost paths in graphs with negative weights (but still no negative cycles) is the following: Add a constant value c to all edge weights so that there are no negative weights and then use Dijkstra's algorithm to nd the minimum cost paths. Either prove that this approach works or find a small counter example that shows that it won't work. 4. Consider the following statement: If a directed graph G = (V;E) is acyclic and no edge between u and v is in E, then at least one of (u; v) or (v; u) can be added to E without creating a cycle. Give a (short) proof that this statement is correct or find a counterexample.

image text in transcribed

Dijkstra's algorithm

void dijkstra (vertix s)

cleandata();

s.dist =0 ;

pq.insert(s);

while (!pq.isEmpty()) {

v= pq.deletMin();

if (v.visited)

continue;

v.visited = true;

for (all (v,w) image text in transcribed E) {

if(v.dist + e.cost

w.dist = v.dist + e.cost;

w.prev = v;

pq.enque(w);

}

}

}

}

Graph 2 Graph 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions