There is a cycle if an adjacent is visited and present in recursion call stack recur [ ]
else if ( visited . elementAt ( adj [ v ] . elementAt ( i ) ) == true && recur . elementAt ( adj [ v ] . elementAt ( i ) ) == true ) return true ; } recur . set ( v , false ) ; return false ; }