$title Use of dynamics sets, predecessor, successor graphs set nodes /1*7/; alias (i,j,nodes); * note that pred is a 2D static set set pred(i,j) 'i is the predecessor of j' / 1.2*3 2.5 3.4 4.5 5.6*7 /; option pred:0:0:1; display pred; set succ(i,j) 'i is the successor of j'; succ(i,j) = yes$pred(j,i); * note that succ is a dynamic 2D set * generate a 1D dynamic set whose elements are the leaves of the graph set leaves(i) 'nodes that have no successor'; leaves(i) = yes; loop(succ(i,j), leaves(j) = no; ); * can do this just using pred * generate a 1D dynamic set whose elements are the roots of the graph set roots(i) 'nodes that have no predecessor'; roots(i) = yes; loop(pred(i,j), roots(j) = no; ); if (card(roots) gt 0, display roots; else display 'error: must have at least one root'; );