title: Bellman-Ford :- Why are there N-1 iterations for calculating mindistance?
body: <pre><code>def calculateShortestPath(self,vertexList,edgeList,startVertex):
      startVertex.minDistance=0
  
      for i in range(0,len(vertexList)-1):#N-1 ITERATION
          for edge in edgeList:
              #RELAXATION PROCESS
              u=edge.startVertex
              v=edge.targetVertex
              newDistance=u.minDistance+edge.weight
              if newDistance&lt;v.minDistance:
                  v.minDistance=newDistance
                  v.predecessor=u
      for edge in edgeList:# FINAL ITERATION TO DETECT NEGATIVE CYCLES
          if self.hasCycle(edge):
              print("NEGATIVE CYCLE DETECTED")
              self.HAS_CYCLE=True
              return
  </code></pre>
  
  <p>The above function is a part of the implementation of the Bellman-Ford Algorithm. My question is that how can one be sure that after N-1 iterations , the minimum distance has been calculated ? In case of Dijkstra it was understood that once the priority queue has gone empty all the shortest paths have been created but I can't understand the reasoning behind the N-1 over here.</p>
  
  <pre><code>N-Length of the Vertex List.
  Vertex List-contains the different vertex.
  EdgeList-List of the different Edges.
  </code></pre>
  
  <p>The implementation may be wrong since I read it from a tutorial video.Thanks For The Help</p>