\setcounter{AlgoLine}{0}
\DontPrintSemicolon
\KwData{Undirected connected network $R = (V, E, w)$, a given vertex $s \in V$}
	\KwResult{Minimum spanning tree $T = (V, E_T)$}
	\ForAll{Vertex $i \in V$}
	{$\lambda_i \leftarrow \infty$ \tcp*[r]{Cost for introducing $i$ into $T$}
		$pred_i \leftarrow \varnothing$ \tcp*[r]{Predecessor of $i$}
	}
	$\lambda_s = 0$;
	$E_T \leftarrow \varnothing$\\
	$L \leftarrow V$ \tcp*[r]{List of vertices to introduce in $T$}
	\While{$L \ne \varnothing$}
	{\lnl{line:primremove}Remove the vertex $i$ with the smallest $\lambda_i$ from $L$ \\
		\If {$i \ne s$}{$E_T \leftarrow E_T \cup \{pred_i, i\}$}
		\ForAll{Vertex $j$ adjacent to $i$}
		{\If{$j \in L$ and $\lambda_j > w(\{i, j\})$}
			{\lnl{line:primupdate}$\lambda_j \leftarrow w(\{i, j\})$\\
				$pred_j \leftarrow i$\\
			}
		}
	}
