refactored some logic out of main into graph_generator