code: def breadth_first_search(G, seed):
      
      G = asgraph(G)
      N = G.shape[0]
  
      order = np.empty(N, G.indptr.dtype)
      level = np.empty(N, G.indptr.dtype)
      level[:] = -1
  
      BFS = amg_core.breadth_first_search
      BFS(G.indptr, G.indices, int(seed), order, level)
  
      return order, level
docs: Breadth First search of a graph.
  
      Parameters
      ----------
      G : csr_matrix, csc_matrix
          A sparse NxN matrix where each nonzero entry G[i,j] is the distance
          between nodes i and j.
      seed : int
          Index of the seed location
  
      Returns
      -------
      order : int array
          Breadth first order
      level : int array
          Final levels
  
      Examples
      --------
      0---2
      |  /
      | /
      1---4---7---8---9
      |  /|  /
      | / | /
      3/  6/
      |
      |
      5
      >>> import numpy as np
      >>> import pyamg
      >>> import scipy.sparse as sparse
      >>> edges = np.array([[0,1],[0,2],[1,2],[1,3],[1,4],[3,4],[3,5],
                            [4,6], [4,7], [6,7], [7,8], [8,9]])
      >>> N = np.max(edges.ravel())+1
      >>> data = np.ones((edges.shape[0],))
      >>> A = sparse.coo_matrix((data, (edges[:,0], edges[:,1])), shape=(N,N))
      >>> c, l = pyamg.graph.breadth_first_search(A, 0)
      >>> print(l)
      >>> print(c)
      [0 1 1 2 2 3 3 3 4 5]
      [0 1 2 3 4 5 6 7 8 9]