http://qs321.pair.com?node_id=838797


in reply to Finding all connected nodes in an all-against-all comparison

Hi,

take a look at the Graph module:

use warnings; use strict; use Data::Dumper; use Graph; my $g = Graph->new(directed => 1); $g->add_vertex("Contig$_") for (1..11); while (my $line = <DATA>){ my @nodes = split( /\s+/,$line ); $g->add_edge( @nodes ); } print Dumper $g->weakly_connected_components; __DATA__ Contig1 Contig2 Contig1 Contig3 Contig2 Contig1 Contig2 Contig3 Contig3 Contig1 Contig3 Contig2 Contig3 Contig4 Contig4 Contig3 Contig4 Contig5 Contig6 Contig7 Contig7 Contig6 Contig8 Contig9 Contig9 Contig10 Contig10 Contig8 Contig10 Contig11 Contig11 Contig10
Cheers, Christoph