Find the loop from the directed graph