What do you mean by node-segment?

You could store it as a lists of friends-IDs accessible by ID, in perl that would be a Hash of Arrays (or even a Hash of Hashes).

Or as nodes of IDs with pointers to any friend-node, which is maybe what you meant with node-segment. But although pointers aka links are available in perl and could be stored in a Hash of Arrays too, it has no advantages over the first mentioned approach that I can see. And it is less natural to use in perl. And you would have to store the ID of the user into the first entry of the array so you know who it is when you access a friends list coming from a link instead of the hash, which is mayor badness and a recipe for creating inconsistent data structure

The first approach also translates naturally to database storage in a relational database.

Examples of using the data structure Hash of Arrays can be found here and here in perldoc


In reply to Re: best way to keep track of who's friends with whom by jethro
in thread best way to keep track of who's friends with whom by keiusui

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.