#!/usr/bin/perl for ($i=1;$ARGV[$i];$i++) { if (open FH,$ARGV[$i]) { my @path; @path=split /\//,$ARGV[$i]; $label[$count]=$path[$#path]; $label[$count]=~s/\.+[^\.]*$//; while () { $edge[$count]{" \"$1\" -> \"$2\";\n"}=1 if /^\s*"(\S+)"\s*->\s*"(\S+)"\s*;\s*$/; } close FH; $count++; } } for ($i=1;$i<$count;$i++) { my ($e,$str); $e=$edge[$i]; $str=join '',sort keys %$e; for ($j=0;$j<$i;$j++) { if ($edge[$j]) { $e=$edge[$j]; if ($str eq join '',sort keys %$e) { $label[$j]="$label[$j] $label[$i]"; undef $edge[$i]; last; } } } } for ($i=$j=0;$i<$count;$i++) { if ($edge[$i]) { $edge[$j]=$edge[$i]; $label[$j]=$label[$i]; $j++; } } $count=$j; for ($i=0;$i<$count;$i++) { my $e; $e=$edge[$i]; foreach (keys %$e) { $edge{$_}++; } } if ($ARGV[0] eq 'dot') { print "digraph \"g\" {\n"; foreach (sort keys %edge) { print if $edge{$_}==$count; } print "}\n"; } elsif ($ARGV[0] eq 'html') { print <<'EOF'; Distance Table EOF print ''; for ($i=1;$i<$count;$i++) { print ""; } print "\n"; for ($i=0;$i<$count-1;$i++) { print ""; for ($j=1;$j<=$i;$j++) { print ''; } for ($j=$i+1;$j<$count;$j++) { my $diff; foreach (keys %edge) { $diff++ if $edge[$i]{$_}!=$edge[$j]{$_}; } printf '',$diff/(keys %edge)*10000; } print "\n"; } print "\n
Distance Table
$label[$i]
$label[$i]%d
\n\n\n\n"; } elsif ($ARGV[0] eq 'txt') { my $leng; for ($i=0;$i<$count;$i++) { my $len; $len = length $label[$i]; $leng = $len if $leng < $len; } for ($i=0;$i<$count;$i++) { printf "%${leng}s:",$label[$i]; foreach (sort keys %edge) { print $edge[$i]{$_}?'XX':'--'; } print "\n"; } }