Update CreateGraph.py

Code refactor.