return minimum moves from source to sink
return level [ d ] NEW_LINE def isSafe ( i , j , M ) : NEW_LINE global N NEW_LINE if ( ( i < 0 or i >= N ) or ( j < 0 or j >= N ) or M [ i ] [ j ] == 0 ) : NEW_LINE return False NEW_LINE return True NEW_LINE