code: def bellman_ford(G, seeds, maxiter=None):
      
      G = asgraph(G)
      N = G.shape[0]
  
      if maxiter is not None and maxiter < 0:
          raise ValueError('maxiter must be positive')
      if G.dtype == complex:
          raise ValueError('Bellman-Ford algorithm only defined for real\
                            weights')
  
      seeds = np.asarray(seeds, dtype='intc')
  
      distances = np.empty(N, dtype=G.dtype)
      distances[:] = max_value(G.dtype)
      distances[seeds] = 0
  
      nearest_seed = np.empty(N, dtype='intc')
      nearest_seed[:] = -1
      nearest_seed[seeds] = seeds
  
      old_distances = np.empty_like(distances)
  
      iter = 0
      while maxiter is None or iter < maxiter:
          old_distances[:] = distances
  
          amg_core.bellman_ford(N, G.indptr, G.indices, G.data, distances,
                                nearest_seed)
  
          if (old_distances == distances).all():
              break
  
      return (distances, nearest_seed)
docs: Bellman-Ford iteration.
  
      Parameters
      ----------
      G : sparse matrix
  
      Returns
      -------
      distances : array
      nearest_seed : array
  
      References
      ----------
      CLR