refactored some of the graph code and added r/w from file for the graph