Cycle detection using dfs -doubt in code

In the code we set visited[2] = true while traversing neighbours of 1 right . So will visit 2 again since the conditon given to only visit neighbour of 4 if visited[nbr]==false.Isnt 2 already marked true in visited array

@vaishnavi20001611

Can u please share the code? I will be able to help you much better if you send the code