1 PROCEDURE (G: reduced graph)
2 Let R be an empty set
3 Let P(u) precedessors of u
4 //assign integer labels sinks and isolated vertices.
5 FOR each u in G
6 IF P(u) is empty
7 Assign an integer i to u
8 Increment i by 1
9 Add v to U
10 Remove v from G
11 ENDIF
12 END LOOP
13
14 WHILE G not empty
15 //Find a set of unlabelled vertices
16 //that has no unlabelled predecessors
17 FOR each v in G
18 IF (v is not labelled && P(v) are labelled)
19 Add v to R
20 Remove v from G
21 ENDIF
22 END LOOP
23
24 ENDWHILE
25 END PROCEDURE