1 PROCEDURE (G: proper digraph, max: maximum iteration number)
2 Let prev_crossings be previous the computed crossing numbers
3 Let iteration be the number of iterations
4 Let crossings be the number of crossings
5 Let i be the integer number
6 Let Li be the layer i
7 WHILE iteration < max
8 FOR each Li in G
9 //Compute the number of crossing for 2 layered graph
10 crossings = crossings + crossingNumber(Li);
11 END LOOP
12 //Compare against the previous calculation.
13 //If crossings is greater than previous number of
14 //crossings, then the procedure is done.
15 IF crossings > prev_crossings
16 EXIT the WHILE LOOP
17 //If not, continue to calculate the crossing number
18 ELSE
19 prev_crossings = crossings
20 ENDIF
21 Increment iterator by 1
22 ENDWHILE
23 END PROCEDURE