Modifoed mincut algorthithm