graph generator code