Solution to the chapter 21 problem

The following algorithm will solve the problem:

Here is an iterative algorithm to find the most expensive edge in the cycle:

If the most expensive edge on that path has a weight greater than that of the new edge, remove that expensive edge and put the new edge into the graph.

Homework assignment

As an alternative to the iterative algorithm using BFS and a search that runs from v back to u we can also solve this problem by modifying DFS.

Modify the DFS algorithm to find the most expensive edge on the path from u to v and return that edge to you.

Implement this algorithm in C++ and use it to solve the chapter 21 problem.