Here is an exercise in the Algorithm Design Manual.
Consider the problem of determining whether a given undirected graph G = (V, E) contains a triangle
Here is what I think :
The origianl BFS solution is incorrect as pointed above. But we can modify the DFS. Assign numbers to the nodes visited as we visit each vertex in the DFS. Now, if we reach a vertex( in the question I saw cross edges, there are none in an undirected graph), we check its adjacency list and suppose one vertex is discovered(but not processed, cannot happen), then we check its number. If the difference is 2 then there is a cycle of length 3.