awk scripts for connection matrix - (nf)
kolstad at parsec.UUCP
kolstad at parsec.UUCP
Fri Jun 3 13:42:08 AEST 1983
#N:parsec:42500010:000:1147
parsec!kolstad Jun 1 13:41:00 1983
Here are two awk scripts to help you manipulate the connection list
(in another note). One of the scripts ("doubler") creates the other
triangle of the connection matrix; the other creates a human readable
connection map.
doubler:
--------------------------------------------------------
# this file takes a set of records of form "a b" and
# outputs two records for each one: "a b" and "b a"
#
BEGIN { FS = " " }
$1 != $2 {print $1 " " $2; print $2 " " $1}
--------------------------------------------------------
awk -f doubler < connects > bigconnects
makemap:
--------------------------------------------------------
# given a long set of sorted pairs of connectivities:
# a b / a c / d e / d f
# this gives: a <tab> b c
# d <tab> e f \
# <tab > g h [continued line]
#
NR == 1 {src = $1; line = $1 " "; n = 0}
$1 == src {if(n>8){print line " \\"; line = " " $2; n = 1} else {line = line " " $2; n++}}
$1 != src {print line; src = $1; line = $1 " " $2; n = 0}
END {print line}
-------------------------------------------------------------
sort -u bigconnects > bigconnects2
awk -f makemap bigconnects2 > newmap
More information about the Comp.sources.unix
mailing list