Theory:
A hash in perl uses
at least 32 bits for the bucket index, so that would translate to 2Gig buckets, so a perfectly filled hash could contain 2Gig elements (if not perfectly filled, it could be a lot more or a lot less). Also, depending on your machine, it could use more bits for the index.
Practice:
This code:
#!/usr/bin/perl -w
use strict;
$|=1;
my @nodes;
for (1 .. 3000) {
push @nodes,{ number => $_ };
print "\r$_" unless $_ % 1000;
}
my @edges;
for (0 .. 2500000) {
push @edges,{ s => \ $nodes[$_ % 3000], d => \ $nodes[3000 - $_ %
+3000] };
print "\r$_" unless $_ % 1000;
}
print "\ndone, press enter to exit";
my $dummy = <STDIN>;
Eats up about 430 Mb on my machine:
perl v5.8.0 built for i386-linux-thread-multi.
It's not super-fast, but it still works. However, how much memory Graph::Directed objects will take, and how long operations on the graphs will take is something you'll have to test for yourself.
Joost.
--
#!/usr/bin/perl -np
BEGIN{@ARGV=$0}s(^([^=].*)|=)()s;
=Just another perl hacker\
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.