code: def bfs_edges_generator(graph, source, reverse=False):
      """Edges frontiers generator using breadth-first search.
  
      Parameters
      ----------
      graph : DGLGraph
          The graph object.
      source : list, tensor of nodes
          Source nodes.
      reverse : bool, default False
          If True, traverse following the in-edge direction.
  
      Returns
      -------
      list of edge frontiers
          Each edge frontier is a list or tensor of edge ids.
  
      Examples
      --------
      Given a graph (directed, edges from small node id to large, sorted
      in lexicographical order of source-destination node id tuple):
      ::
  
                2 - 4
               / \\
          0 - 1 - 3 - 5
  
      >>> g = dgl.graph(([0, 1, 1, 2, 2, 3], [1, 2, 3, 3, 4, 5]))
      >>> list(dgl.bfs_edges_generator(g, 0))
      [tensor([0]), tensor([1, 2]), tensor([4, 5])]
      """
      assert isinstance(
          graph, DGLGraph
      ), "DGLHeteroGraph is merged with DGLGraph, Please use DGLGraph"
      assert (
          len(graph.canonical_etypes) == 1
      ), "bfs_edges_generator only support homogeneous graph"
      # Workaround before support for GPU graph
      gidx = graph._graph.copy_to(utils.to_dgl_context(F.cpu()))
      source = utils.toindex(source, dtype=graph._idtype_str)
      ret = _CAPI_DGLBFSEdges_v2(gidx, source.todgltensor(), reverse)
      all_edges = utils.toindex(
          ret(0), dtype=graph._idtype_str
      ).tousertensor()
      # TODO(minjie): how to support directly creating python list
      sections = utils.toindex(ret(1)).tonumpy().tolist()
      edge_frontiers = F.split(all_edges, sections, dim=0)
      return edge_frontiers
  
file_path: dgl/python/dgl/traversal.py
imports: from __future__ import absolute_import
  from .None import backend, utils
  from ._ffi.function import _init_api
  from .heterograph import DGLGraph
label_desc: Use image node_id 2 for calling a global function with example usage: bfs_edges_generator(graph, source, reverse) and returns: edge_frontiers