Connecting Tech Pros Worldwide Forums | Help | Site Map

How to make matrix?

Newbie
 
Join Date: Jan 2007
Posts: 1
#1: Jan 31 '07
I’ve been given a file
1 2 15
1 3 16
2 3 20
and so on…First two values of the input file represents graph nodes and the third one is distance between them. I know the number of nodes(in previous example number of nodes is 4, counting starts from 0)
I need perl code that makes a matrix that looks like this:
0 0 0 0
0 0 15 16
0 15 0 20
0 16 20 0
Thanks in advance!!!!!

miller's Avatar
Moderator
 
Join Date: Oct 2006
Location: San Francisco, CA
Posts: 830
#2: Jan 31 '07

re: How to make matrix?


Read the tutorial on complex data structures. There's a section specifically on "Arrays of Arrays"

http://perldoc.perl.org/perldsc.html...-of-arrays-AoA
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#3: Jan 31 '07

re: How to make matrix?


Check your PM's Miller.
Reply