algorithms for graphs 4214467