Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Finding all connected nodes in an all-against-all comparison

by lamprecht (Friar)
on May 06, 2010 at 22:00 UTC ( #838797=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
Re^2: Finding all connected nodes in an all-against-all comparison
by LanX (Sage) on May 07, 2010 at 14:15 UTC
    UPDATE: ARGH sorry this reply was meant for the OP!

    Thats really not trivial and more complicated than I thought because of edge cases (not covered in your sample code)

    So I can fully recommend using an already tested and optimized graph module because all solutions I had so far need to be rewritten for performance reasons...

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://838797]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-01-21 18:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (59 votes). Check out past polls.

    Notices?