Dijkstra's Algorithm and Cycles
问题 It's stated in a book that "Dijkstra's algorithm only works with Directed Acyclic Graphs". It appears the algorithm works for graphs with cycles too as long as there are no negative cycles. Is that correct? Edit 1: The book "Grokking Algorithms" -Aditya Bhargava. Chapter 7. Page 122. 回答1: I'm the author of Grokking Algorithms . Sorry for this error—Dijkstra's algorithm does work on graphs with cycles, as long as it is a positive weight cycle. I have updated the errata page to reflect this