using dynamic sets to find roots and leaves of a graph 09/24/01 11:05:26 PAGE 1 GAMS Rev 121 Linux/Intel 2 3 * graph has seven nodes 4 set i/1*7/; 5 alias (i,j); 6 7 * define (directed) arc set 8 set arc(i,j)/1.2, 1.3, 3.4, 2.5, 4.5, 5.6, 5.7/; 9 10 * define sets or leaf nodes and root nodes 11 set leaves(i), roots(i); 12 13 * define the leaves to be those nodes that are not the start 14 * node for an arc. 15 leaves(i) = yes; 16 loop(arc(i,j), 17 leaves(i) = no; 18 ); 19 20 * define the roots to be those that are never the finish 21 * node for an arc 22 roots(i) = yes; 23 loop(arc(i,j), 24 roots(j) = no; 25 ); 26 27 display leaves, roots; COMPILATION TIME = 0.000 SECONDS 0.7 Mb LNX200-121 using dynamic sets to find roots and leaves of a graph 09/24/01 11:05:26 PAGE 2 E x e c u t i o n GAMS Rev 121 Linux/Intel ---- 27 SET leaves 6, 7 ---- 27 SET roots 1 EXECUTION TIME = 0.000 SECONDS 1.3 Mb LNX200-121 USER: Computer Sciences Dept. G010628:1627AS-LNX University of Wisconsin-Madison DC2621 **** FILE SUMMARY INPUT /afs/cs.wisc.edu/u/s/w/swright/public/html/635/examples/graph-dynamic.gms OUTPUT /afs/cs.wisc.edu/u/s/w/swright/public/html/635/examples/graph-dynamic.lst