Graph algorithms from ML book