modified graph.py