Refactor graph code to create timestamped directory