I'm a bit confused about stopping at Kth iteration on the Bellman-Ford algorithm to find the shortest path of at most length k from s to t.Let me show you a graph and explain you what I understand:At first iteration, I will have:Shortest path to get to A is S->A (cost 1)Shortest path to get to B is S->B (cost 4)Shortest path to get to T is still unknownAt second iteration I will have:Shortest path to get to A is S->A (cost 1)Shortest path to get to B is A->B (cost 2(A->B) + cost 1(S->A) = 3) updated!Shortest path to get to T is B->TBut now going to B takes 2 edges instead of 1, so going to T is 3 edges away now: S->A->B->T, and this has happened in 2 iterations.What am I understanding wrong?
Shortest path between 2 vertices using at most K edges using Bellman-Ford
graphs;graph theory;shortest path;dynamic programming