reorganized graph-searching functions