Improve graph.py