Question: Let G be a weighted undirected connected graph. Write, in pseudo-code, an algorithm sumCrossEdges(G) that performs DFS of G and returns the sum of weights

Let G be a weighted undirected connected graph. Write, in pseudo-code, an algorithm sumCrossEdges(G) that performs DFS of G and returns the sum of weights of edges that get labeled as 'cross' edges.

Answer in pseudo-code that resembles the below example for a BFS on the same question.

Let G be a weighted undirected connected graph. Write, in pseudo-code, an

Algorithm sumCrossEdges (G) sum = 0 for e E G.edges(0) mark e unvisited for v E G.vertices() mark v unvisited s - G.vertices().getFirst() Q new empty sequence Q.insertlast(s) mark s visited while Q is not empty u = Q.first() for all e E G.incidentEdges(v) do w opposite(v, e) if w is not visited mark ww set label of e to DISCOVERY Q.insertLast (w) else if e is not visited set label of e to CROSS sum sume.getWeightO return sum

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!