The Bellman-Ford algorithm is similar to the Dijkstra algorithm, and is based on the relaxation operation, that is, gradually replacing the estimated shortest path value with a more accurate value until the optimal solution is obtained. In the calculation of these two algorithms, the estimated distance between each edge is larger than the real value, so it will be replaced by the minimum length of the newly found path. However, Dijkstra's algorithm uses a greedy algorithm to select unprocessed nodes with the smallest weights, and then performs relaxation operations on its outgoing edges; while the Bellman-Ford algorithm simply relaxes all edges | V | Operation, where | V | is the number of points in the graph. In repeated calculations, the number of edges with the shortest path correctly calculated continues to increase until all edges have calculated the correct path. Such a strategy makes the Bellman-Ford algorithm suitable for more types of input than the Dijkstra algorithm.