Using this function you can separate 2 different logic: 1-searching and walking on the graph, 2 - do something into some vertex.