\begin{algorithm}
\caption{LexBFS Algorithm}
\begin{algorithmic}[1]
\Function{LexBFS}{$G=(V, E)$}
\State Let $P$ be an empty list \Comment{Initialize the permutation}
\State Let $Q$ be an empty queue \Comment{Initialize the queue}
\For{each vertex $v \in V$}
\State Mark $v$ as not visited
\EndFor
\For{each vertex $v \in V$}
\If{$v$ is not visited}
\State \Call{BFS}{$v, P, Q$} \Comment{Call BFS from unvisited vertices}
\EndIf
\EndFor
\State \textbf{return} $P$ \Comment{Return the lexicographic BFS ordering}
\EndFunction
\Function{BFS}{$s, P, Q$}
\State Mark $s$ as visited
\State Enqueue $s$ to $Q$
\While{$Q$ is not empty}
\State Dequeue $u$ from $Q$
\State Append $u$ to $P$
\For{each neighbor $v$ of $u$}
\If{$v$ is not visited}
\State Mark $v$ as visited
\State Enqueue $v$ to $Q$
\EndIf
\EndFor
\EndWhile
\EndFunction
\end{algorithmic}
\end{algorithm}
所有\EndFor
都返回错误“缺失数字,视为零”,所有\If
都返回错误“\algocf@Ifstrip 的参数有多余的”。我不知道我做错了什么。我使用的包是
\usepackage{algorithm} \usepackage[noend]{algpseudocode}