Mental Model
Find the shortest paths between every pair of points by checking if going through a middle point is better than going directly.
Analogy: Imagine you want to find the quickest way to travel between every pair of cities. Sometimes going through a third city is faster than going straight. You check all possible middle cities to find the best routes.
Graph with 4 nodes: (0)---5---(1) | \ | 10 3 1 | \ | (3)---2---(2) Distance matrix before: [0, 5, 3, 10] [∞, 0, 1, ∞] [∞, ∞, 0, 2] [∞, ∞, ∞, 0]