[Solved]: What is the difference between shortest distance and shortest path?

Problem Detail: I am studying graph currently. I found a question, which asks for

  1. The List A[] which shows shortest distances between $V$ and every other vertex
  2. The List B[] which shows shortest paths between $V$ and every other vertex

as subpoints. I don’t think the question wants me to compute the same values twice, but I don’t know what the difference between shortest distance and shortest path is. Can anyody explain?

Asked By : gyanu

Answered By : FrankW

As @randomA already indicated in a comment, a shortest path from $v$ to $w$ is a sequence of vertices (that describes a path from $v$ to $w$, which is shortest among such sequences).
The shortest distance on the other hand is the length of a shortest path, i.e. a number. As a sidenote, be aware that there can be multiple shortest paths (but only one shortest distance). Thus, you might want to check, if the the question requires you to find one or all of them.
Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/32036  Ask a Question  Download Related Notes/Documents