nodes: 0, module; 1, function_definition; 2, function_name:sorted_bfs_edges; 3, parameters; 4, block; 5, identifier:G; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_statement; 14, identifier:source; 15, None; 16, comment:"""Produce edges in a breadth-first-search starting at source.
  
      Neighbors appear in the order a linguist would expect in a syntax tree.
      The result will only contain edges that express a dominance or spanning
      relation, i.e. edges expressing pointing or precedence relations will
      be ignored.
  
      Parameters
      ----------
      G : DiscourseDocumentGraph
  
      source : node
         Specify starting node for breadth-first search and return edges in
         the component reachable from source.
  
      Returns
      -------
      edges: generator
         A generator of edges in the breadth-first-search.
      """; 17, comparison_operator:source is None; 18, block; 19, assignment; 20, assignment; 21, assignment; 22, assignment; 23, identifier:queue; 24, block; 25, identifier:source; 26, None; 27, expression_statement; 28, identifier:xpos; 29, call; 30, identifier:visited; 31, call; 32, identifier:source_children; 33, call; 34, identifier:queue; 35, call; 36, expression_statement; 37, try_statement; 38, assignment; 39, identifier:horizontal_positions; 40, argument_list; 41, identifier:set; 42, argument_list; 43, identifier:get_child_nodes; 44, argument_list; 45, identifier:deque; 46, argument_list; 47, assignment; 48, block; 49, except_clause; 50, identifier:source; 51, attribute; 52, identifier:G; 53, identifier:source; 54, list; 55, identifier:G; 56, identifier:source; 57, list; 58, pattern_list; 59, subscript; 60, expression_statement; 61, if_statement; 62, identifier:StopIteration; 63, block; 64, identifier:G; 65, identifier:root; 66, identifier:source; 67, tuple; 68, identifier:parent; 69, identifier:children; 70, identifier:queue; 71, integer:0; 72, assignment; 73, comparison_operator:child not in visited; 74, block; 75, expression_statement; 76, identifier:source; 77, call; 78, identifier:child; 79, call; 80, identifier:child; 81, identifier:visited; 82, expression_statement; 83, expression_statement; 84, expression_statement; 85, expression_statement; 86, call; 87, identifier:iter; 88, argument_list; 89, identifier:next; 90, argument_list; 91, yield; 92, call; 93, assignment; 94, call; 95, attribute; 96, argument_list; 97, call; 98, identifier:children; 99, expression_list; 100, attribute; 101, argument_list; 102, identifier:grandchildren; 103, call; 104, attribute; 105, argument_list; 106, identifier:queue; 107, identifier:popleft; 108, identifier:sorted; 109, argument_list; 110, identifier:parent; 111, identifier:child; 112, identifier:visited; 113, identifier:add; 114, identifier:child; 115, identifier:get_child_nodes; 116, argument_list; 117, identifier:queue; 118, identifier:append; 119, tuple; 120, identifier:source_children; 121, keyword_argument; 122, identifier:G; 123, identifier:child; 124, identifier:child; 125, call; 126, identifier:key; 127, lambda; 128, identifier:iter; 129, argument_list; 130, lambda_parameters; 131, subscript; 132, call; 133, identifier:x; 134, identifier:xpos; 135, identifier:x; 136, identifier:sorted; 137, argument_list; 138, identifier:grandchildren; 139, keyword_argument; 140, identifier:key; 141, lambda; 142, lambda_parameters; 143, subscript; 144, identifier:x; 145, identifier:xpos; 146, identifier:x
code: def sorted_bfs_edges(G, source=None):
      """Produce edges in a breadth-first-search starting at source.
  
      Neighbors appear in the order a linguist would expect in a syntax tree.
      The result will only contain edges that express a dominance or spanning
      relation, i.e. edges expressing pointing or precedence relations will
      be ignored.
  
      Parameters
      ----------
      G : DiscourseDocumentGraph
  
      source : node
         Specify starting node for breadth-first search and return edges in
         the component reachable from source.
  
      Returns
      -------
      edges: generator
         A generator of edges in the breadth-first-search.
      """
      if source is None:
          source = G.root
  
      xpos = horizontal_positions(G, source)
      visited = set([source])
      source_children = get_child_nodes(G, source)
      queue = deque([(source, iter(sorted(source_children,
                                          key=lambda x: xpos[x])))])
      while queue:
          parent, children = queue[0]
          try:
              child = next(children)
              if child not in visited:
                  yield parent, child
                  visited.add(child)
                  grandchildren = get_child_nodes(G, child)
                  queue.append((child, iter(sorted(grandchildren,
                                                   key=lambda x: xpos[x]))))
          except StopIteration:
              queue.popleft()