Я пытаюсь создать BFS, пока Python выдает мне объект int, а не повторяющуюся ошибку.
Часть кода:
visited, queue = set(), collections.deque( ((0, 0), [ (0, 0) ] ) )
# tuple: current location, path
while queue:
vertex = queue.popleft()
i,j=vertex[0]
if i+1<=dim-1 and (i+1, j) not in visited and X[i+1, j]==0:
visited.add(( i+1, j) )
temp=( (i+1, j), vertex[1]+[(i+1, j)])
if temp[0]==(dim-1, dim-1):
return True, temp[1]
queue.append(temp)
Под циклом while я делаю любую другую итерацию!