Commit 0aa13088 authored by Chad Barb's avatar Chad Barb

.Top to gif graph conversion.

parent 7debf737
#!/usr/local/bin/perl -w
$TOPPER = "~barb/bin/topper";
$NEATO = "~barb/bin/neato";
while ($_ = shift) {
if (/\-o(.*)/) {
$outfile = $1 || shift || die "Bad arguments! '-o' must be followed by output
file name.\n";
} else {
if (defined $infile) {
warn "Specifying second infile \"$_\" ignores previous infile \"$infile\".\n";
}
$infile = $_;
}
}
defined $outfile or die "Must define output file with -o parameter.\n";
defined $infile or die "Must specify input file.\n";
(-r $infile) or die "Input file \"$infile\" not readable.\n";
# (-w $outfile) or die "Output file \"$infile\" not writeable.\n";
exit (system( "cat $infile | $TOPPER | $NEATO -Tgif -o $outfile" ) / 256);
#!/usr/local/bin/perl -w
%color = (
"pc850", "skyblue",
"pc", "skyblue",
"shark", "darkblue",
"lan", "green",
"delay", "orange"
);
print "graph G {\n";
while (<>) {
if (/^node/) {
my ($nodename, $nodetype) = /^node\s+(\S+)\s+(\S+)/;
$nodename =~ s/[^\w]/_/g;
print "{node [width = .1, height = .1, shape = box,";
if (exists $color{ $nodetype }) {
print "color = " . $color{ $nodetype };
} else {
warn "Warning! Unknown color for \"$nodetype\"--using default.\n";
print "color = skyblue";
}
print "] $nodename}\n";
} elsif (/^link/) {
my ($lhs, $rhs) = /^link\s+\S+\s+(\S+)\s+(\S+)/;
$rhs =~ s/[^\w]/_/g;
$lhs =~ s/[^\w]/_/g;
print "$lhs -- $rhs;\n";
}
}
print "}\n";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment