searching a cyclic graph