\begin{algorithm}
\begin{algorithmic}
\FUNCTION{DFS}{\UPPERCASE{$G$}, $s, t$}
\STATE $visited \gets $ List()
\STATE $S \gets $ Stack()
\STATE \CALL{Add}{$visited, s$}
\STATE \CALL{Push}{$q, s$}
\STATE
\WHILE{\CALL{Length}{$q$} $\neq$ 0}
\STATE $current = $ \CALL{Pop}{$q$}
\IF {$current = t$}
\RETURN{$t$}
\ENDIF
\STATE
\FORALL { $n \in $ \call{Adjacent}{\UPPERCASE{$G$}, $current$} }
\IF {$n \notin $ visited}
\STATE \CALL{Add}{$visited, current$}
\STATE \CALL{Push}{$q, current$}
\ENDIF
\ENDFOR
\ENDWHILE
\ENDFUNCTION
\end{algorithmic}
\end{algorithm}
function DFS(G, s, t) {
let visited = [];
let q = [];
visited.push(s);
q.push(s);
while(q.length !== 0) {
let current = q.pop();
if (current.equals(t)) {
return t;
}
let adjacent = G.getAdjacentNodes(current);
adjacent.forEach(function(node) {
if (!visited.includes(node)) {
visited.push(node);
q.push(node);
}
});
}
}