Let's start by generating specifications for what you're trying to achieve.
First start with a short, one-line summary of the project. I'll make one up ... Summarize activity of users at my web site.
Then generate a description, in English, of what you want to achieve. I'll make stuff up, guessing what i think you might be thinking
- Read the data file, line by line, specifying the edges of a graph.
- Split the line into a command, the 'from' node, and the 'to' node.
- For a connection 'command', if the 'from' node and 'to' node have not been seen, add them.
- If the 'from' node has been seen, but the 'to' has not, then ... do something
- if the 'from' node has not been seen, but the 'to' node has, then ... do something
Once you have an idea of what you want to achieve, then you can consider how to implement it.
At the moment, if you are asked to "connect 1 2", you create a hash { 1 => 1, 2 => 1}. How do you know whether that is "connect 1 2" or "connect 2 1"?
If this is homework, you should ask your teacher or TA.
As Occam said: Entia non sunt multiplicanda praeter necessitatem.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.