Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: treat pairs, set as one item: looking for better way

by remiah (Hermit)
on Oct 19, 2013 at 11:58 UTC ( #1058905=note: print w/ replies, xml ) Need Help??


in reply to Re: treat pairs, set as one item: looking for better way
in thread treat pairs, set as one item: looking for better way

Hello LanX ! and oh my god !!!

#!/usr/bin/perl use Graph::Undirected; use strict; use warnings; my $g = Graph::Undirected->new; my @key_array = 'a' .. 'z'; my @set_array = ( ['a', 'b'], ['e','f'], ['f','g'] ); $g->add_vertex( $_ ) for @key_array; $g->add_edge( $_->[0], $_->[1] ) for @set_array; print "$_\n" for sort { length($b) <=> length($a) || $a cmp $b } map {join( ',', @$_) } $g->connected_components;
I totally forgot about Graph module until you tell me.
I would like to read your pages you gave me.

Really thanks for your reply.


Comment on Re^2: treat pairs, set as one item: looking for better way
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-09-01 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (16 votes), past polls