Line 55 of code

if neigbour of current element exist int the map,then it would have bool value 1,but if it does not exist int the map(not visited) why would it give value 1?

We have used not of visited[i].
!(visited[i]).
If visited[i] = 0 ie not visited, condition gives 1. Hence we visit it.
if visited[i]=1 ie already visited, condition gives 0. Hence we don’t visit it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.