\begin{algorithm}
\begin{algorithmic}
\FUNCTION{BFS}{\UPPERCASE{$G$}, $s, t$}
\STATE $visited \gets $ List()
\STATE $Q \gets $ Queue()
\STATE \CALL{Add}{$visited, s$}
\STATE \CALL{Enqueue}{$q, s$}
\STATE
\WHILE{\CALL{Length}{$q$} $\neq$ 0}
\STATE $current = $ \CALL{Dequeue}{$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{Enqueue}{$q, current$}
\ENDIF
\ENDFOR
\ENDWHILE
\ENDFUNCTION
\end{algorithmic}
\end{algorithm}
function BFS(G, s, t) {
let visited = [];
let q = [];
visited.push(s);
q.push(s);
while(q.length !== 0) {
let current = q.shift();
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);
}
});
}
}