How to modify bellman ford algorithm to find shortest path with at most k edges?

The input is a directed graph with (possibly negative) weighted
edges, a source node s, a target node t, and a positive integer k. The task is to compute
the length of a shortest path from s to t that has at most k edges, or to report that there
is no path from s to t with k edges.

1 answer 1