dp[mask][last] = cheapest path from city 0 visiting exactly the cities in mask, ending at last. Watch masks fill in popcount order, each transition adding one city.
step 0
Graph & tour so far
mask = {0}
Filling dp[mask][last] from smaller masks.
source state (mask \\ last) updated state bit set (city in mask)
dp[mask][last] table
Press Step to begin. We build dp[mask][last] by extending each path with one unvisited city; masks are processed in increasing order so dependencies are always ready.
Self-contained visualization. Held-Karp DP, counting cost in the (min, +) sense. The base case is dp[{0}][0] = 0; the final tour adds dist[last][0].
Complexity O(2n·n2) time, O(2n·n) space. See junior.md and professional.md for the recurrence and its proof.