#!/usr/athena/bin/perl

$ct=1;
while(<>){
    chop;
    $host = $_;
    $tr = `traceroute -n $host`;
    @lines = split("\n", $tr);
    $prev=0;
    foreach $l (@lines){
	split(" ",  $l);
	last if ($_[1] eq "*");
	if(!$id{$_[1]}){
	    $id{$_[1]} = $ct;
	    $ct++;
	}
	if($prev ne ""){
	    if(!$link{"$prev-$id{$_[1]}"}){
		print "Link $prev-$id{$_[1]} ($_[1])\n";
		$link{"$prev-$id{$_[1]}"}=1;
	    }
	}
	$prev = $id{$_[1]};
    }
	$r = "";
	for $i (keys %id){
	print "$i = $id{$i}\n";
}
    for $l (keys %link){
	$r .= "$l,";
    }
    chop($r);
    print "$r\n";
}
