doing function travelInShortestPath
update function travelInShortestPath