\renewcommand{\baselinestretch}{1}
\begin{algorithm}[t]
\caption{Generalized version of the reduction algorithm}
\label{alg:general}

\begin{algorithmic}[1]
{\footnotesize
\REQUIRE $M$ : A storage structure for partial matches
\REQUIRE $G = (V,E)$ : The input graph
\REQUIRE $Rules$ : A set of reduction rules
\REQUIRE $Reducts$ : An set of base reduct graphs
\REQUIRE $Q$ : a queue or stack supporting constant time tests for membership

\STATE $Q \leftarrow $ all vertices of $G$ with small degree

\WHILE {$Q$ is not empty}
    \STATE $v \leftarrow remove~next(Q)$

    \FOR {each $rule$ in $Rules$}
        \FOR {each connected subgraph $b$ of restricted nodes in $rule$}
            \FOR {each appropriately sized connected subgraph $s$ of small nodes containing $v$}
                \IF {$s$ is isomorphic to $b$}
                    \IF {$s$ completes a match of $rule$ (all other matches already stored in $M$)}
                        \STATE Apply the reduction $rule$ to $G$ at $s$
                        \STATE Add to $Q$ any vertices that are now small and not currently in $Q$
                        \STATE Remove from $M$ all partial matches involving deleted vertices.
                        \STATE {\bf break} out of all the {\bf for} loops
                    \ELSE
                        \STATE add the partial match to $M[rule][b][border~nodes(s)]$, \COMMENT{with appropriate bookkeeping to keep track which nodes are stored where in $M$.}
                    \ENDIF
                \ENDIF
            \ENDFOR
        \ENDFOR
    \ENDFOR
\ENDWHILE

\STATE {\bf return} whether $G$ is isomorphic to any of the graphs in $Reducts$
}

\end{algorithmic}
\end{algorithm}
\renewcommand{\baselinestretch}{1.5}
