#!/freeware/bin/gnu-tools/gawk -f BEGIN { if(ARGC <= 1) {printf("Use: WLAT_RENUM_MIN \n") > "/dev/stderr"; printf("\tRenumber the nodes so that every node uses the lowest possible number.\n") > "/dev/stderr"; exit(0); } # Read and convert the word graph fname = ARGV[1]; for(iline=1;(getline= 0) for(nr=0;nr in node_used;nr++); node_used[nr] = 1; node_xlat[$2] = nr; printf("O %i %s\n",nr,$3); } else if($1 == "C") {printf("C %i\n",nr=node_xlat[$2]); delete node_used[nr]; delete node_xlat[$2]; } else if($1 ~ "^[AD]$") {$2 = node_xlat[$2]; $3 = node_xlat[$3]; printf("%s\n",$0); } else if($1 == "File:") {for(i in node_used) delete node_used[i]; for(i in node_xlat) delete node_xlat[i]; 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); }