
zing
Novice
Oct 3, 2012, 10:25 AM
Post #3 of 3
(584 views)
|
|
Re: [Laurent_R] Finding subgraphs induced by a set of given vertices.
[In reply to]
|
Can't Post
|
|
Yes they are commutative. The code below does it partially. Is it efficient ??
#!/usr/bin/perl use Data::Dumper; use strict; use warnings; my @S = do { open my($data), '<', \q{b c a a c d d e b}; map { [ split ] } readline $data; }; print Dumper \@S; for my $QT ( [qw[ a b c d ]], [qw[ b e d ]] ){ print Dumper $QT; for my $triplet ( @S ){ my %Pie; undef @Pie{@$QT}; delete @Pie{ @$triplet }; #~ warn scalar keys %Pie ; #~ warn scalar @$QT; print "@$triplet\n" if keys(%Pie) <= ( @$QT - @$triplet ) ; } } -------OUTPUT-----------
$VAR1 = [ [ 'b', 'c', 'a' ], [ 'a', 'c', 'd' ], [ 'd', 'e', 'b' ] ]; $VAR1 = [ 'a', 'b', 'c', 'd' ]; b c a a c d $VAR1 = [ 'b', 'e', 'd' ]; d e b
|