# Package algorithm to use

Please, what package can i use in latex to have the model of algorithm in the figure ?

-
– N.N. Sep 29 '12 at 11:33
Have you tried algorithm2e? – Marc van Dongen Sep 29 '12 at 11:36
algorithm2e let me to write a pseudo algorithm ? because my algorithm is just a set of sentences, it is not a true algorithm.. – researcher Sep 29 '12 at 11:53
– Werner Sep 30 '12 at 4:08
See Werner's excellent answer at Print programs with its proper syntax. – Peter Grill Sep 30 '12 at 8:35

As has been mentioned in a comment, the algorithm2e package gives you the desired layout:

\documentclass{article}
\usepackage[ruled]{algorithm2e}

\begin{document}

\begin{algorithm}
\Begin{
$V \longleftarrow U$\;
$S \longleftarrow \emptyset$\;
\For{$x\in X$}{
$NbSuccInS(x) \longleftarrow 0$\;
$NbPredInMin(x) \longleftarrow 0$\;
$NbPredNotInMin(x) \longleftarrow |ImPred(x)|$\;
}
}
\caption{My Algorithm}
\label{alg:test}
\end{algorithm}

\end{document}


-
i have used your code but i don't have the line that connects begin to end. have you an idea please – researcher Sep 30 '12 at 9:47
with \usepackage[ruled,vlined]{algorithm2e} i have resolved the problem – researcher Sep 30 '12 at 9:56
Please i ask if it's possible to have this same format with package algorithmic, because i should use it – researcher Sep 30 '12 at 17:29
@researcher You can do it with algorithmicx (notice the "x" at the end) which is much better, can do everything algorithmic does and they are compatible. See [this answer by Werner] to learn how to achieve the desired layout using algorithmicx. – Gonzalo Medina Sep 30 '12 at 23:17
The function names don't look very pretty. $\textit{NbSuccInS}(x) \longleftarrow 0$ looks nice and informal. – Marc van Dongen Apr 15 '13 at 13:33