CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [Laurent_R] Representing a connection matrix of graph: Edit Log



rushadrena
Novice

Aug 9, 2012, 9:15 PM


Views: 3704
Re: [Laurent_R] Representing a connection matrix of graph

Hi Laurent . I clubbed my code along with your code. But while trying to run it ,my pc goes out of memory/cpu (the while loop isnt getting terminated).



Code
# Takes input in the form 'a,b|c'  
# How to run : perl code.pl 'a,b|c' 'c,d|e' 'a,d|e'
# Outputs a NX3 for the above input data.
# Outputs connections in Nx2 form
use Data::Dumper;


$arg=join(' ',@ARGV);
@det=split //, $arg;

for ($i=0; $i <=8; $i++)
{$trip[$i]=$det[2*$i];}

my @array;
while (@trip) {
push(@array, [ splice(@trip, 0, 3) ]);
}
print "@$_\n" for @array;

for ($i=0; $i <=2; $i++)
{
for ($j=0; $j <=1; $j++)
{ $con[$i][$j]=$array[$i][$j];}
}
print "\n==========connections======\n";
print "from->to\n";
print " @$_\n" for @con;

my %HoA;
while (@con) {
($key, $value) = split;
push @{$HoA{$key}}, $value;
}


OUTPUT
[xguest@localhost Downloads]$ perl code.pl 'a,b|c' 'c,d|e' 'a,d|e'
a b c
c d e
a d e

==========connections======
from->to
a b
c d
a d
Out of memory!


(This post was edited by rushadrena on Aug 9, 2012, 9:17 PM)


Edit Log:
Post edited by rushadrena (Novice) on Aug 9, 2012, 9:17 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives