#!/usr/bin/perl -w use strict; use Graph::Undirected; my $graph = Graph::Undirected->new(); my @data = map { [ grep defined, split /\s+/ ] } <DATA>; foreach my $line ( 1 .. scalar @data ) { $graph->add_edges( map { $line => $_ } @{ $data[ $line - 1 ] } ) } my @sets = $graph->strongly_connected_components; for (@sets) { printf "{ %s }\n", join ' ', sort { $a cmp $b } @$_; } __END__ a b c d e f b g h i j k l m f
In reply to Re: Building Networks of Matches
by simonm
in thread Building Networks of Matches
by bowsie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |