next up previous contents
Next: Implementation Up: The Floodfill Algorithm Previous: Basic Theory   Contents

The Algorithm


\begin{algorithmic}
\STATE $l = 0$
\STATE $s = d$
\STATE $t = \emptyset$
\WH...
...ILE
\STATE $l = l + 1$
\STATE swap $s$ with $t$
\ENDWHILE
\end{algorithmic}

In this algorithm, $s$ is a set of cells being processed, while $t$ is a set of cells to be processed in the next iteration. $l$ is the ``level'' of cells, or the distance from a destination. $d$ is the initial set of destination cells. $n(c)$ is a set of reachable neighbors of cell $c$. $v(c)$ is the value assigned to cell $c$, $v(c)$ is undefined for all cells initially.



Tak Auyeung 2003-09-29