#!/freeware/bin/gnu-tools/gawk -f BEGIN { if(ARGC <= 1) {printf("Use: WLAT_RENUM_MAX \n") > "/dev/stderr"; printf("\tGive the nodes a sequential numbering based on the order in which\n\tthey are opened. Also put all open node commands at the beginning\n\tand all close node commands at the end.\n") > "/dev/stderr"; exit(0); } # Read and convert the word graph fname = ARGV[1]; for(iline=1;(getline= 0) nr = nr_nodes++; node_xlat[$2] = nr; node_time[nr] = $3; } else if($1 == "C") delete node_xlat[$2]; else if($1 ~ "^[AD]$") {$2 = node_xlat[$2]; $3 = node_xlat[$3]; arcs[nr_arcs++] = $0; } else if($1 == "File:") {if(nr_nodes > 0) {for(i=0;i=-4; ) {if(i in node_time) printf("C %i\n",i); delete node_time[i]; } for(i=nr_nodes;--i>=0; ) printf("C %i\n",i); nr_nodes = nr_arcs = 0; } if(EOF) break; printf("%s\n",$0); } else printf("Error: unknown command '%s' at line %i\n",$0,iline) > "/dev/stderr"; } close(fname); exit(0); }