Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: how to convert two lists into adjacency matrix

by linuxer (Curate)
on Apr 13, 2009 at 21:59 UTC ( #757293=note: print w/replies, xml ) Need Help??

in reply to how to convert two lists into adjacency matrix

Please have a look at How do I compose an effective node title? and at Markup in the Monastery.

Don't misuse <pre>-Tags here.

To your question: you're telling what you have as data source and what the desired result should look like.

But you don't show where you have your problems...

So, where's your problem hidden? What do you have problems with?

Are you looking for someone to write your code?

Update: You could do something like this (if you want to do it on your own):

  • read data
    • read data file and ignore header line
    • chomp and split each line into two pieces
    • create an entry in a hash-of-hash (HoH); $hash{id1}->{id2} = 1;
    • store id2 in an array if not already in that array
  • output:
    • for each key in %hash print that key; check for every entry in your array if an entry in the HoH exists, if so, print 1, if not, print 0.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://757293]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2018-03-22 14:00 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (276 votes). Check out past polls.