This is a simple question from algorithms theory.
The difference between them is that in one case you count number of nodes and in other number of edges on the shortest
The answer by Daniel A.A. Pelsmaeker and Yesh analogy is excellent. I would like to add a bit more from hackerrank tutorial. Hope it helps a bit too.