Graph search uniform cost algorithm