Debian Codegraph @

texmf-dist/doc/latex/algorithm2e/algorithm2e_exAlgoDisjdecomp.tex

raw
1 \IncMargin{1em}
2 \begin{algorithm}
3 \SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}
4 \SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}
5 \SetKwInOut{Input}{input}\SetKwInOut{Output}{output}
6
7 \Input{A bitmap $Im$ of size $w\times l$}
8 \Output{A partition of the bitmap}
9 \BlankLine
10 \emph{special treatment of the first line}\;
11 \For{$i\leftarrow 2$ \KwTo $l$}{
12 \emph{special treatment of the first element of line $i$}\;
13 \For{$j\leftarrow 2$ \KwTo $w$}{\label{forins}
14 \Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}\;
15 \Up$\leftarrow$ \FindCompress{$Im[i-1,]$}\;
16 \This$\leftarrow$ \FindCompress{$Im[i,j]$}\;
17 \If(\tcp*[h]{O(\Left,\This)==1}){\Left compatible with \This}{\label{lt}
18 \lIf{\Left $<$ \This}{\Union{\Left,\This}}
19 \lElse{\Union{\This,\Left}}
20 }
21 \If(\tcp*[f]{O(\Up,\This)==1}){\Up compatible with \This}{\label{ut}
22 \lIf{\Up $<$ \This}{\Union{\Up,\This}}
23 \tcp{\This is put under \Up to keep tree as flat as possible}\label{cmt}
24 \lElse{\Union{\This,\Up}}\tcp*[h]{\This linked to \Up}\label{lelse}
25 }
26 }
27 \lForEach{element $e$ of the line $i$}{\FindCompress{p}}
28 }
29 \caption{disjoint decomposition}\label{algo_disjdecomp}
30 \end{algorithm}\DecMargin{1em}