Is there an already implemented data structure that I can use in order to assign to an object
(in my case an Edge), an integer? I am reading a graph from a file , 10 mil vertices , 60 mil edges and I assign to each edge , a cost , using a map ( costs.put(e,cost) ).
I create the costs map in this way :
costs = new HashMap<Edge,Integer>();
The exception that it gives is :
java.lang.OutOfMemoryError: Java heap space
at java.util.HashMap.resize(Unknown Source)
at java.util.HashMap.addEntry(Unknown Source)
at java.util.HashMap.put(Unknown Source)
HashMapis the correct data structure for a basicMap. The problem you are having is that the JVM is not being instructed to reserve enough space to keep the file contents in memory. Start the JVM with a-Xmxflag. For instance-Xmx1Gparameter will allow it to use 1 Gigabyte of memory.