Graph algorithms in Python