Hi.
Do you only need to detect that such a loop occurred? Or also trace the path, say for some kind of graphical effect?
In the first case, I can think of a couple approaches.
One is to maintain an adjacency matrix, take the nth power of that (where n = 1 + number of edges, I believe), and then see if there are any non-0 elements on the diagonal.
You might also try a flood fill (there are some topics in the forum, I believe, or the Code Exchange), adapted to only follow edges, and stop if you run across the same vertex twice. (This is basically the DFS approach outlined here.)
From there you can probably trace the path fairly easily, or convert it to something amenable to a path-finding algorithm. (You’d have to decide whether you care, in the situation where more than one loop shows up.)
If you’re especially brave, I do have code for loops, though it’s may not be what you’re after. It’s written for something along the lines of Pepper II or Amidar, where the level is mostly static, but more than a few things rebuild the scene on the fly and it doesn’t seem to suffer. (You can ignore anything about dots and shapes, and probably most if not all stuff about direction.)