kevin-wayne / algs4

Algorithms, 4th edition textbook code and libraries
http://algs4.cs.princeton.edu/code/
GNU General Public License v3.0
7.42k stars 2.68k forks source link

Update BellmanFordSP.java. Make it more in line with the text in the book. #120

Closed YRFT closed 1 year ago

YRFT commented 1 year ago

In the text of chapter 4.4 in the book (P677) and the web site (see [here](https://algs4.cs.princeton.edu/44sp/#:~:text=We%20amortize%20the%20cost%20of%20this%20check%20by%20performing%20this%20check%20only%20after%20every%20Vth%20call%20to%20relax().)), it says:

We amortize the cost of this check by performing this check only after every Vth call to relax().

This update brings the code more in line with the description in these texts.

kevin-wayne commented 1 year ago

I believe p. 677 was updated in the textbook (June 2014) to say "after every Vth edge relaxation" instead of "after every 5th call to relax()." This is the desired rule and matches the code. I've updated the booksite to use the same language. Thanks for bringing to our attention.