I am given an algorithm that is supposed to find the length of the shortest cycle in an undirected graph with unit edge lengths. I have to show that the algorithm does not always work by providing a counterexample. I am having problems coming up with an example that can show that this algorithm does not always work.
Algorithm:
- Do a depth-first search, keeping track of the level of each vertex.
- Each time a back edge is encountered, compute the cycle length and save it if it is smaller than the shortest one previously seen.
Any suggestions/ help will be appreciated