This will depend on some more subtle definitions, for example, if the edges have backlinks. Then it's easy, because you can just follow the tree feedback. Otherwise, I canβt think of a way to do this without O (lg number of nodes) space, because you need to remember at least the nodes βaboveβ.
Update
Oh wait, of course, this can be done in O (1) space by trading space time. Wherever you would like to make feedback, you save your place and execute BFS by tracking the very last node until you find yours. Then go back to the last node visited and continue.
The problem is that O (1) is space, but O (n ^ 2) is time.
Another update
Suppose we reach node n_i and we want to reach the parent element node, which we will call wlg n_j. We have identified the outstanding root node n_0.
Modify the first breath search algorithm so that when it follows the directional edge (n_x, n_y), the efferent or βincomingβ node is saved. That way, when you follow (n_x, n_y), you save n_x.
When you start BFS again from n_0, you are guaranteed (suppose it is really a tree) that at a SOME point you will go to the edge (n_j, n_i). At this point, you are observing that you are back at n_i. You saved n_j, and you know that the reverse edge (n_i, n_j).
Thus, you get this single rollback with two additional cells, one for n_0 and one for the "saved" node. This is O (1)
I am not sure about O (n ^ 2) - it was late, and it was a difficult day, so I do not want to make evidence. I am sure that O ((| N | + | E |) ^ 2), where | N | and | E | - the size of the sets of vertices and edges, respectively.