Here’s a quick way to graph a two-column Comma Separated Values file, where the first column points to the second. I use this for email virtual mappings.
For example, even a short, 6-line CSV file is difficult to decipher manually:
bob@example.com,bob@mx1.example.com
bob.smith@example.com,bob@mx1.example.com
bob@mx1.example.com,”bob,prodigy@10.1.1.5″
jane@example.com,jane@mx1.example.com
tom@elsewhere.example.com,bob@example.com
jane@mx1.example.com,bob.smith@example.com
Running the graphcsv.pl script will produce, depending on how you configure the output, a layout file as such:
digraph test {
graph [ratio=compress, overlap=false];
node [label="\N"];
“bob@example.com” [label="bob@example.com"];
“bob@mx1.example.com” [label="bob@mx1.example.com"];
“bob.smith@example.com” [label="bob.smith@example.com"];
“bob,prodigy@10.1.1.5″ [label="bob,prodigy@10.1.1.5"];
“jane@example.com” [label="jane@example.com"];
“jane@mx1.example.com” [label="jane@mx1.example.com"];
“tom@elsewhere.example.com” [label="tom@elsewhere.example.com"];
“bob.smith@example.com” -> “bob@mx1.example.com”;
“bob@example.com” -> “bob@mx1.example.com”;
“bob@mx1.example.com” -> “bob,prodigy@10.1.1.5″;
“jane@example.com” -> “jane@mx1.example.com”;
“jane@mx1.example.com” -> “bob.smith@example.com”;
“tom@elsewhere.example.com” -> bob@example.com;
}
The twopi output of the graph would then appear as:

Code looks like:
#!/usr/bin/perl -w
#
# graphcsv.pl: converts 2-column comma-separated value input into a directed
# graph. This isn’t very well tested. See doc to convert output. Or, you
# could just change the “as_canon” last line to “as_svg” or “as_gif”. I find
# it easier to save as “canon,” the text layout output, to easily test different
# layouts. For instance, “twopi” may work better than “dot,” depending.
#
# usage: graphcsv.pl < input.csv > output.canon
#
# Make sure you apply the patch below for the perl GraphViz module
# http://www.snakelegs.org/2006/09/18/quoting-names-in-the-graphviz-perl-module/
use strict;
use GraphViz;
use Text::CSV_XS;
my $g = GraphViz->new(layout => ‘dot’, directed => 1, ratio => ‘compress’, overlap => ‘false’);
my $csv = Text::CSV_XS->new();
while (<>) {
my $status = $csv->parse($_);
my @columns = $csv->fields();
$g->add_edge($columns[0] => $columns[1]);
}
print $g->as_canon;