But how do I keep track of the previous node? For example, lets say the BITMAP is something like this:
0001
0011
0110
Now, if I need to push the "1" points (0, 3),(1, 2), (1,3), (2,1), (2,2) in the queue and apply BFS to each of the "1"s. Distance to the neighbouring pixels is 1+previous pixel. But my question is how do I keep track of previous visited gridpoint?
nodes
top.x and top.y
would correspond to x and y co-ordinates of the pixel, right?
distance=distance+1;
if(distance < distance[x][y])
distance[x][y]=distance;
s.push(node(top.x+1, top.y));
s.push(node(top.x, top. y+1));
s.push(node(top.x, top.y-1));
s.push(node(top.x-1, top.y));