2

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

researcher
  • 4,555

1 Answers1

1

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}

enter image description here

Gonzalo Medina
  • 505,128
  • 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 09:47
  • with \usepackage[ruled,vlined]{algorithm2e} i have resolved the problem – researcher Sep 30 '12 at 09: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. –  Apr 15 '13 at 13:33