Refactoring make_graphs.r