Now use BFS to find if there is any possible path or not . Initialize the queue which holds the discovered cells whose neighbors are not discovered yet .
qu = queue . Queue ( ) NEW_LINE rect [ 0 ] [ 0 ] = 1 NEW_LINE qu . put ( [ 0 , 0 ] ) NEW_LINE