[Tex/LaTex] How to add a comments with the `algorithm2e` package

algorithm2e

I am using algorithm2e package to write an algorithm and I am trying to add line 3 and 4 in the code in the screen shot as comment with \tcc{} but without seccuss. How can I add a comments with the algorithm2e package?

enter image description here

Code:

\documentclass{article}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e} 
\renewcommand{\baselinestretch}{1.5}
\usepackage{amsmath}

\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{2 graphs  $T$ and $\acute{T}$ with nodes V and $\acute{V}$.}
\KwResult{Find whether $T$ and $\acute{T}$ are isomorph.}

function($T$, $\acute{T}$) \\
 \Indp covert $T$ to $P_v$ and $\acute{T}$ to $\acute{P_v}$ ;\\
 $d=deg(P_T) \leq h(T)$ and $S=\{1,2,3,\dots,2h(T)\}$; \\
  $\acute{d} =deg(\acute{P_T}) \leq h(\acute{T})$ and $\acute{S}=\{1,2,3,\dots,2h(\acute{T})\}$; \\

 \eIf{$Pr[P_v = \acute{P_v}] = \frac{d}{S}=\frac{h(T)}{2h(T)} ==\frac{1}{2}$}{
    return true;
    }{
    return false;}

\end{algorithm}
\end{document}

Best Answer

I simply tried

\tcc{$d=deg(P_T) \leq h(T)$ and $S=\{1,2,3,\dots,2h(T)\}$}
\tcc{$\acute{d} =deg(\acute{P_T}) \leq h(\acute{T})$ and $\acute{S}=\{1,2,3,\dots,2h(\acute{T})\}$}

and it worked without problems. Simply be careful to remove ; \\ from the end of the line.

Related Question