August 2026
Intermediate
144 pages
4h 23m
English
Suppose that you need to find the fastest walking route between two locations in a city. To do so, you would model roads as graph edges connecting corners (vertices), with travel times as weights, and you would seek the minimal-cost route.
In this chapter, we develop two algorithms for building the shortest path between two vertices in a weighted graph. We arrive at both algorithms by again weakening postconditions. The Bellman-Ford algorithm allows negative weights. It is not greedy because it modifies—not ...
Read now
Unlock full access