I really don't know what are your nodes, and when they disconnect from others
With your example data, you can simplify to:
use strict; use warnings; my $queryCount=0; my $answeredCount=0; my %connected=(); while(<>) { print; chomp($_); if (/q (\d+) (\d+)/) { $answeredCount++ if ( defined $connected{$1} and $connected{$2 +}); $queryCount++; } elsif (/c (\d+) (\d+)/) { $connected{$1}=1; $connected{$2}=1; } } print "$answeredCount,".($queryCount-$answeredCount)."\n";
I suspect you should use a hash more complex may be:
$connected{firstSet}{$n1}=1; # or better $connected{1}{x}=1; $connected{secondSet}{$n1}=1; # or better $connected{2}{x}=1;
And detect when you have to delete one node from connected in the correspondient set (delete $connected{x}{N})
I hope that help, be sure to read perldata
Regards,
In reply to Re: How to process with huge data's
by i5513
in thread How to process with huge data's
by arivu198314
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |