The general case for a graph is closed cirquits (some call these: cycles or primary cycles) detection (Google that). Lot’s of topics on that matter in code related forums/sites (but keep in mind that quite a few solutions that are offered around are 100% crap) :
If memory serves well Petras posted a thread on that matter recently (but I can’t recall the name).
For cirquits with more that 4 members and if you want surfaces (not the ideal solution)… things start to get complicated: for example patch is out of question (huge elapsed times [IF a patch is valid to apply, that is] etc etc)
For loops that contain up to 4 members you can find cirquits via VV connectivity (plus: you’ll need island detection in your graph [also done via VV]). Easy via code, have no idea how to do it with components.