@Override
   public Graph load() {
      final long startTime = System.currentTimeMillis();
      
      DataInputStream dis = null; 
      try {
         {         
            final InputStream inputStreamToUse;
            
            assert(this.filename != null || this.inputStream != null);
            if(this.inputStream != null) {
               inputStreamToUse = this.inputStream;
            } else {
               final File file = new File(filename);
               
               if (!file.exists()) {
                  return null;
               }
               
               inputStreamToUse = new FileInputStream(file);
            }
            
            dis = new DataInputStream(inputStreamToUse);
         }
         
         final char numWords = dis.readChar();
         final String uniqueAndSortedWords[] = new String[numWords];
         for (char wordId = 0; wordId < numWords; wordId++) {
            uniqueAndSortedWords[wordId] = dis.readUTF();
         }
         
         final DictionaryLookup dict = new DictionaryLookupBinarySearch(uniqueAndSortedWords);
         
         final int numWordHistories = dis.readInt();
         
         // Choose the hashmap's initial capacity to be enough for all the words (and include 
         // a little more spare capacity to cover the default load factor of 0.75).
         final int initialCapacity = (numWordHistories + (numWordHistories / 4));
         
         final Map<String, Transitions> wordHistoryToTransitions = new HashMap<String, Transitions>(initialCapacity);
         
         for (int historiesIndex = 0; historiesIndex < numWordHistories; historiesIndex++) {
            final Transitions t = new Transitions();
            
            wordHistoryToTransitions.put(dis.readUTF(), t);
            
            for(char stillToRead = dis.readChar(); stillToRead > 0; stillToRead--) {
               final char targetWordId = dis.readChar();
               final char numerator = dis.readChar();
               final char denominator = dis.readChar();
               
               t.addTransition(targetWordId, numerator, denominator, stillToRead > 1);
            }
         }
         
         final Graph reconstituted = new Graph(dict, wordHistoryToTransitions);
         
         System.out.println("Loading from "+filename+" took " + (System.currentTimeMillis() - startTime) + "ms");
         
         return reconstituted;
      } catch (final Exception anything) {
         anything.printStackTrace();
         return null;
      } finally {
         if(dis != null) {
            try {
               dis.close();
            } catch(Throwable anything){}
         }
      }
   }