#!/usr/bin/env gawk -f # BEGIN block: Initialize global variables and print graph header BEGIN { print "digraph G {"; } # Process each input line { if (NF != 2) { printf("Warning: Skipping malformed line: %s\n", $0) > "/dev/stderr"; next; } edges[$1, $2] = 1; # Store edge as key in associative array } # END block: Print graph edges and footer END { for (combined in edges) { split(combined, edge, SUBSEP); printf("\t\"%s\" -> \"%s\";\n", edge[1], edge[2]); } print "}"; }