E814 Refactoring of graph_generator.rb