about to try less elegant but clearer code
graph.py works like a treat