#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    19
    Rep Power
    0

    Representing a connection matrix of graph


    Hi all , I have this form of representation in array (N X 2) for my graph(undirected):-

    a b

    c d

    a d

    c a

    f g

    f h
    What i want is its representation in this form my %connections=(a=>[b,d],c=>[d,a],f=>[g,h]);
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    828
    Rep Power
    496
    Hi,

    If I understand what you want, you may try something like this (assuming the data is read from a file):

    Perl Code:
    my %HoA; 
    while (<FILE>) { 
         my ($key, $value) = split; 
         push @{$HoA{$key}}, $value; 
    }

IMN logo majestic logo threadwatch logo seochat tools logo