In the pseudocode above, s denotes the source node and the weight of a link from node u to node v is represented as w [u, v]. Each node in the graph maintains the cost of the shortest path from the source node to itself along with the index of the node that precedes it in the shortest path. During each iteration, the cost and predecessor node index of all the nodes with an incoming link are updated. This results in a shortest-path tree with the source node as its root being expanded such that during each iteration its height is incremented by one hop. The runtime complexity of the Bellman–Ford algorithm is O(ne) where n is the number of nodes and e is the number of links.