Algorithms for directed graphs