Refactoring of graph_generator.rb