| 1 |
\begin{algorithm} |
| 2 |
\DontPrintSemicolon |
| 3 |
\KwData{$G=(X,U)$ such that $G^{tc}$ is an order.} |
| 4 |
\KwResult{$G'=(X,V)$ with $V\subseteq U$ such that $G'^{tc}$ is an |
| 5 |
interval order.} |
| 6 |
\Begin{ |
| 7 |
$V \longleftarrow U$\; |
| 8 |
$S \longleftarrow \emptyset$\; |
| 9 |
\For{$x\in X$}{ |
| 10 |
$NbSuccInS(x) \longleftarrow 0$\; |
| 11 |
$NbPredInMin(x) \longleftarrow 0$\; |
| 12 |
$NbPredNotInMin(x) \longleftarrow |ImPred(x)|$\; |
| 13 |
} |
| 14 |
\For{$x \in X$}{ |
| 15 |
\If{$NbPredInMin(x) = 0$ {\bf and} $NbPredNotInMin(x) = 0$}{ |
| 16 |
$AppendToMin(x)$} |
| 17 |
} |
| 18 |
\nl\While{$S \neq \emptyset$}{\label{InRes1} |
| 19 |
\nlset{REM} remove $x$ from the list of $T$ of maximal index\;\label{InResR} |
| 20 |
\lnl{InRes2}\While{$|S \cap ImSucc(x)| \neq |S|$}{ |
| 21 |
\For{$ y \in S-ImSucc(x)$}{ |
| 22 |
\{ remove from $V$ all the arcs $zy$ : \}\; |
| 23 |
\For{$z \in ImPred(y) \cap Min$}{ |
| 24 |
remove the arc $zy$ from $V$\; |
| 25 |
$NbSuccInS(z) \longleftarrow NbSuccInS(z) - 1$\; |
| 26 |
move $z$ in $T$ to the list preceding its present list\; |
| 27 |
\{i.e. If $z \in T[k]$, move $z$ from $T[k]$ to |
| 28 |
$T[k-1]$\}\; |
| 29 |
} |
| 30 |
$NbPredInMin(y) \longleftarrow 0$\; |
| 31 |
$NbPredNotInMin(y) \longleftarrow 0$\; |
| 32 |
$S \longleftarrow S - \{y\}$\; |
| 33 |
$AppendToMin(y)$\; |
| 34 |
} |
| 35 |
} |
| 36 |
$RemoveFromMin(x)$\; |
| 37 |
} |
| 38 |
} |
| 39 |
\caption{IntervalRestriction\label{IR}} |
| 40 |
\end{algorithm} |