$title using dynamic sets to find roots and leaves of a graph * graph has seven nodes set i/1*7/; alias (i,j); * define (directed) arc set set arc(i,j)/1.2, 1.3, 3.4, 2.5, 4.5, 5.6, 5.7/; * define sets or leaf nodes and root nodes set leaves(i), roots(i); * define the leaves to be those nodes that are not the start * node for an arc. leaves(i) = yes; loop(arc(i,j), leaves(i) = no; ); * define the roots to be those that are never the finish * node for an arc roots(i) = yes; loop(arc(i,j), roots(j) = no; ); display leaves, roots;