1
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ One guess is that edges are weighted, distance is measured according to the some of weights, and paths are measured according to length (number of edges). But if you're not sure, ask the professor. $\endgroup$ – Yuval Filmus Oct 17 '14 at 22:29
  • $\begingroup$ i was guessing same answer looking others work but i was not sure. $\endgroup$ – gyanu Oct 17 '14 at 22:31
  • 4
    $\begingroup$ Shortest distance is a number, shortest path is a list of vertices. Those two things are different, I am not sure what your confusion is. $\endgroup$ – InformedA Oct 17 '14 at 22:37
  • $\begingroup$ yes shortest path is a list of vertices. But in array it has numbers which matches number of edges. $\endgroup$ – gyanu Oct 17 '14 at 22:49
  • 1
    $\begingroup$ I can't understand your title and the body contains no actual question. It says that you came across a question but, unless you tell us what the question is, we can't possibly answer it! $\endgroup$ – David Richerby Oct 18 '14 at 0:21
2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.