Moore’s Improvement
Explore the different techniques used to implement Moore's algorithm efficiently.
We'll cover the following...
Deriving Moore’s algorithm from BFS
Neither Moore nor Bellman described the Bellman-Ford algorithm in the form we’ve presented here. Moore presented his version of the algorithm (“Algorithm D”) in the same paper that proposed breadth-first search (“Algorithm A”) for unweighted graphs; indeed, the two algorithms are nearly identical. Although Moore’s algorithm has the same worst-case running time as , it is often significantly faster in practice, intuitively because it avoids checking edges that are “obviously” not tense.
Moore derived his weighted shortest path algorithm by making two modifications to the breadth-first search. First, replace each with in the innermost loop to take the edge weights into account. Second, check whether a vertex is already in the queue before it, so that the queue always contains at most one copy of each vertex.
Following our earlier analysis of breadth-first search, we’ll introduce a token to break the execution of the algorithm into phases. Just like the breadth-first search, each phase begins when the token is ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy