Bfs hash map repersentation

code of bfs using hashmap pair i does not know how to apply

when you apply bfs , you have to store that the position is already visited or not so that you dont get up in an infinite loop.
now you have to apply bfs in 2d matrix , just take positions {i,j} as a pair and insert them in the hashmap, now whenever you insert any new pos in the queue just see wheather hashmap contains that pair or not. there is an inbuild function of map.count();