I am implementing a BFS on a maze represented by a 2D numpy array in Python 3.7.3. This code generates the maze:
for row in range(dim):
# Add an empty array that will hold each cell
# in this row
grid.append([])
for column in range(dim):
grid[row].append(np.random.binomial(1, 0.2, 1)) # Append a cell
if (row == column == dim - 1):
grid[row][column] = 0
grid[0][0] = 0
I would like to avoid using a node class as I have had limited success with it. I want to know how I can represent/store parent-child relationships in a BFS search from the (0,0) position on this maze to the (dimension - 1, dimension - 1) position. Also, given the nature of the graph/maze/grid, I NEED to avoid having children with the same location but different parents. I want to return the shortest list of nodes between the start and end positions.
Thank you for your help.