If you are just trying to plot the nodes, I'd look no further than Graphviz. It even has a Perl module. In that case you don't need all the nodes in memory. Parse your input files and transform them line by line into a large dot file. Of coure GraphViz also takes edge weights into account.