BEGIN { print "digraph G {"} { k = substr($1,1,length($1)-1) } NF == 2 { print k, "[label=\"" $0 "\"];" } NF == 4 { print k, "[label=\"" k " " $3 "\"];" print k, "->", $2, ";" print k, "->", $4, ";" } END { print "}" }