I have a run-time implementation question regarding the 3-dimensional (unweighted 2-)approximation algorithm below: How can I construct the maximum matching M_r in S_r in linear time in line 8?
$X, Y, Z $ are disjoint sets; a matching $M$ is a subset of $S$ s.t. no two triples in $M$ have the same coordinate at any dimension.
$ \text{Algorithm: unweighted 3-dimensional matching (2-approximation)} \\ \text{Input: a set $S\subseteq X \times Y \times Z$ of triples} \\ \text{Output: a matching M in S} $
1) construct maximal matching M in S;
2) change = TRUE;
3) while (change) {
4) change = FALSE;
5) for each triple (a,b,c) in M {
6) M = M - {(a,b,c)};
7) let S_r be the set of triples in S not contradicting M;
8) construct a maximum matching M_r in S_r;
9) if (M_r contains more than one triple) {
10) M = M \cup M_r;
11) change = TRUE;
12) } else {
13) M = M \union {(a,b,c)};
14) }
15) }
[1] http://faculty.cse.tamu.edu/chen/courses/cpsc669/2011/notes/ch9.pdf, p. 326