# PATHFROM.AWK 1.3 # # Created by: Michel Lebel and Gabriela Simonka 98-10-02 # # (c) INRO Consultant Inc. Montreal, 1998 # # Syntax: # # gawk -f pathfrom.awk filename # # Using the transcript file (filename) generated in Module 6.15, this script # yields the path attribute for the shortest paths FROM A SPECIFIED NODE, # based on the selected measure (distance, time or cost) and attributes the # value to the LAST link of the shortest path. # # This information is written to a file (FROMLINK.LST), which will be used # to input the values to a link user defined or extra attribute in Module 2.41. # # Another output file (FROMNODE.LST) lists the origin ROOT node and the # nodes that are inaccessible, along with a marking value to be used as a # node color index in Module 2.13. # # N.B.: The output files FROMNODE.LST and FROMLINK.LST are overwritten each # time this script is run. Therefore rename these files if you desire to # keep this information, (or input the values directly into node/link # attributes). # # # BEGIN {blocka=0; node="fromnode.lst"; link="fromlink.lst"; fileopen[node]=1; fileopen[link]=1;} # # Write header in output files FROMNODE.LST and FROMLINK.LST # $1~/c/ {if ($2=="Shortest") {printf("Link path attribute for paths from root origin based on %s\n",$6)>link; printf(" inode jnode %8s mvalue\n",$6)>>link; printf("Root origin and inaccessible node listing for paths based on %s\n",$6)>node; printf(" inode mvalue\n")>>node;} else next;} # # Obtain INODE, JNODE, and path attribute value ($4): # # If there are only 4 arguments in record, then TO-NODE is inaccessible. # Write inaccessible node ($3) to file with marking value. # # If there are only 5 arguments in record, then TO and FROM NODES are # same. Write root origin node($3) to file with marking value. # $1~/a/ {if (blocka==0) blocka=1; else printf ("%6d %6d %8s 1\n",i,j,path_att)>>link; if (NF>5) {path_att=$4; i=$(NF-1); j=$NF;} else if (NF==4) {blocka=0; printf("%6d 6\n",$3)>>node;} else if (NF==5) {blocka=0; printf("%6d 4\n",$3)>>node;} } # $1!~/a/&&$1!~/c/ {if (NF>1) {i=$(NF-1); j=$NF;} else if (NF==1) {i=j; j=$NF;} } # END {if (blocka==0) blocka=1; else printf ("%6d %6d %s 1\n",i,j,path_att)>>link; close (node); close (link);}