Uniform cost search python graph