algorithms icon indicating copy to clipboard operation
algorithms copied to clipboard

[Oops.] Floyd-Warshall missing initialization with infinity

Open echuber2 opened this issue 5 years ago • 0 comments

Please verify that the error is present in the most recent revision before reporting.

Yes, I believe so as of the June 2019 version.

Chapter number or note title: Section 9.8 on Floyd-Warshall

Page number: 319

Error description: Not all dist[u,v] are initialized, because w(u->v) had only been previously defined as either the weight of an edge (u,v) (if it exists) or as 0 when u==v. (I may have overlooked an overload that w(u->v)=infinity otherwise, though, in which case it wouldn't hurt to make that explicit, as the previously listed algorithms had.)

Suggested fix (if any): The two algorithms on page 319 probably ought to initialize dist[u,v] as infinity, for those (u,v) that are not edges in the graph, and where u!=v. (Or, to be concise, point out that w(v->v)=0 and w(u->v)=inf when (u,v) is not an edge and u!=v.)

Here I've typed -> where what I really mean is →, because that's how I do.

echuber2 avatar Apr 30 '20 20:04 echuber2