Question: Q4. Modify the following DFS algorithm (taken from page 541, in your text book, Cormen, et. AL.) to identify connected components of a graph. You

 Q4. Modify the following DFS algorithm (taken from page 541, in

Q4. Modify the following DFS algorithm (taken from page 541, in your text book, Cormen, et. AL.) to identify connected components of a graph. You can add a new field in the vertex structure called cn. Thus v.cn gives the component number of the node. Initially, all node's cn value are 0. After the execution of the modified DFS, all nodes v's from first component should be v.cn-1, all nodes v's from second component should be v cn 2, and so on. DFS(G) for each vertex u e G. V ucolor= W time 0 for each vertex u eG. V if u.colorW DFS-VISIT (G, u) DFS-VISIT(G, u) time time + 1 u.d time u.color 'G' for each v e G.Adj[u if v.colorW DFS-VISIT(G, v) u,color= 'B' time time +1 u.f time

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!