
rushadrena
Novice
Aug 9, 2012, 9:15 PM
Views: 2629
|
|
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).
# 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)
|