Welcome generate_graph.awk
Signed-off-by: hax <hax@lainlounge.xyz>
This commit is contained in:
parent
a519352291
commit
15e18eead7
1 changed files with 24 additions and 0 deletions
24
generate_graph.awk
Normal file
24
generate_graph.awk
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/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 "}";
|
||||
}
|
Loading…
Add table
Reference in a new issue