0 1 1 2 1 3 1 4 2 4 4 5 #### #!/usr/bin/perl -w use strict; use Graph::Undirected; my $net = Graph::Undirected->new; while () { $net = $net->add_edge( split ); } my @e = $net->edges(); print shift@e,shift@e,"\n" while @e; __END__ 0 1 1 0 #### 01 01 10 10