Question: Consider a weighted undirected graph G=(V,E), where V is the set of nodes and E is the set of edges. Every edge (v,w) between nodes

Consider a weighted undirected graph G=(V,E), where V is the set of nodes and E is the set of edges. Every edge (v,w) between nodes v and w has an associated cost denoted by c(v, w). In the graph, u is an arbitrarily chosen node. Consider the following algorithm run on the graph where the minimum values in line 9 are found using a minheap. Analyze the complexity of the algorithm using O-notation.

Consider a weighted undirected graph G=(V,E), where V is the set of

1 2 Initialization: N' {u} for all nodes v in v if v adjacent to u then D (v) c(u, v) else D (v) 4 5 = = 0o 7 8 9 10 11 12 : Loop find w not in N' such that D (w) is a minimum add w to N' update D(V) for all v adjacent to w and not in N' D(v) min( D(v), D(w) + c(w.v) ) /* new cost to v is either old cost to v or known shortest path cost to w plus cost from w to v */ until all nodes in N' 13 14 15

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!