print "strict graph {\n"; while () { my ($node, @neighbours) = split; print " $node -- $_\n" for @neighbours; } print "}\n";