Hello, thanks for reply.
It took me some time to understand this.
#!usr/bin/perl
use strict; use warnings; use Data::Dumper;
my @key_array = 'a' .. 'z';
my @set_array = ( ['a', 'b'], ['e','f'], ['f','g'],['x','y'] );
# {a =>{a=>1}, b=>{b=>1}, ....}
my %set = map {$_ => {$_ => 't'}} @key_array;
for my $s (@set_array) {
@{$set{$_}}{@$s} = (1) x @$s for @$s;
=my_memo
#same as ...
for (@$s){
@{$set{$_}}{@$s} = (1) x @$s
}
#fill hash value at one time
my %h; @h{ 1 .. 5 }= 'A' ..'F';
#(1) x @$s
if @$s === (a,b) , (1) x @$s === (1,1)
#vertex which has edge information ..
#{ a=>{a=>1,b=>1}, b=>{a=>1,b=>1} ...
=cut
}
my $saw = '';
print map "$_\n",
grep $saw =~ s/^(?!.*$_)/$_ /,
=my_memo
# ??? how it can remove duplicate like "a,b","a,b" or "e,f,g","e,
+f","f,g"
here comes "e,f,g", $saw='', ==> $saw="e,f,g" ==>
+true #saw doesn't have "" replace ^ to "e,f,g"
"a,b" $saw="e,f,g" ==> $saw="a,be,f,g" ==>
+true #saw doesn't have "a,b", replace ^ to "a,b
"a,b" $saw="a,be,f,g" ==> $saw="a,be,f,g" =
+=> false #saw have "a,b" not match;
"e,f" $saw="a,be,f,g" ==> $saw="a,be,f,g" =
+=> false #saw have "e,f" not match;
... removes edge already seen ... really great.
=cut
sort {length $b <=> length $a || $a cmp $b} #sort by length
+ desc || a cmp b
map join(',', sort keys %$_), #"a,b" ... sort
+ed
values %set; # values => {a=
+>1,b=>1}, {a=>1,b=>1},{c=>1},{d=>1},,,
short and great!