Fixed bug with graph loading

Fixed bug with graph loading that could possibly crash the program.