nodes: 0, module; 1, function_definition; 2, function_name:fill_traversals; 3, parameters; 4, block; 5, identifier:traversals; 6, identifier:edges; 7, default_parameter; 8, expression_statement; 9, comment:# make sure edges are correct type; 10, expression_statement; 11, comment:# make sure edges are sorted; 12, expression_statement; 13, comment:# if there are no traversals just return edges; 14, if_statement; 15, comment:# hash edges for contains checks; 16, if_statement; 17, expression_statement; 18, for_statement; 19, comment:# turn the split traversals back into (n,2) edges; 20, expression_statement; 21, if_statement; 22, return_statement; 23, identifier:edges_hash; 24, None; 25, comment:"""
      Convert a traversal of a list of edges into a sequence of
      traversals where every pair of consecutive node indexes
      is an edge in a passed edge list
  
      Parameters
      -------------
      traversals : sequence of (m,) int
         Node indexes of traversals of a graph
      edges : (n, 2) int
         Pairs of connected node indexes
      edges_hash : None, or (n,) int
         Edges sorted along axis 1 then hashed
         using grouping.hashable_rows
  
      Returns
      --------------
      splits : sequence of (p,) int
         Node indexes of connected traversals
      """; 26, assignment; 27, call; 28, comparison_operator:len(traversals) == 0; 29, block; 30, comparison_operator:edges_hash is None; 31, block; 32, assignment; 33, identifier:nodes; 34, identifier:traversals; 35, comment:# split traversals to remove edges; 36, comment:# that don't actually exist; 37, block; 38, assignment; 39, comparison_operator:len(included) > 0; 40, comment:# sort included edges in place; 41, block; 42, else_clause; 43, identifier:splits; 44, identifier:edges; 45, call; 46, attribute; 47, argument_list; 48, call; 49, integer:0; 50, return_statement; 51, identifier:edges_hash; 52, None; 53, expression_statement; 54, identifier:splits; 55, list; 56, expression_statement; 57, identifier:included; 58, call; 59, call; 60, integer:0; 61, expression_statement; 62, comment:# make sure any edges not included in split traversals; 63, comment:# are just added as a length 2 traversal; 64, expression_statement; 65, comment:# no edges were included, so our filled traversal; 66, comment:# is just the original edges copied over; 67, block; 68, attribute; 69, argument_list; 70, identifier:edges; 71, identifier:sort; 72, keyword_argument; 73, identifier:len; 74, argument_list; 75, call; 76, assignment; 77, call; 78, attribute; 79, argument_list; 80, identifier:len; 81, argument_list; 82, call; 83, call; 84, expression_statement; 85, identifier:np; 86, identifier:asanyarray; 87, identifier:edges; 88, keyword_argument; 89, identifier:axis; 90, integer:1; 91, identifier:traversals; 92, attribute; 93, argument_list; 94, identifier:edges_hash; 95, call; 96, attribute; 97, argument_list; 98, identifier:util; 99, identifier:vstack_empty; 100, list_comprehension; 101, identifier:included; 102, attribute; 103, argument_list; 104, attribute; 105, argument_list; 106, assignment; 107, identifier:dtype; 108, attribute; 109, identifier:edges; 110, identifier:copy; 111, attribute; 112, argument_list; 113, identifier:splits; 114, identifier:extend; 115, call; 116, call; 117, for_in_clause; 118, identifier:included; 119, identifier:sort; 120, keyword_argument; 121, identifier:splits; 122, identifier:extend; 123, call; 124, identifier:splits; 125, call; 126, identifier:np; 127, identifier:int64; 128, identifier:grouping; 129, identifier:hashable_rows; 130, identifier:edges; 131, identifier:split_traversal; 132, argument_list; 133, attribute; 134, argument_list; 135, identifier:i; 136, identifier:splits; 137, identifier:axis; 138, integer:1; 139, attribute; 140, argument_list; 141, attribute; 142, argument_list; 143, keyword_argument; 144, keyword_argument; 145, keyword_argument; 146, identifier:np; 147, identifier:column_stack; 148, tuple; 149, identifier:grouping; 150, identifier:boolean_rows; 151, identifier:edges; 152, identifier:included; 153, keyword_argument; 154, identifier:edges; 155, identifier:copy; 156, identifier:traversal; 157, identifier:nodes; 158, identifier:edges; 159, identifier:edges; 160, identifier:edges_hash; 161, identifier:edges_hash; 162, subscript; 163, subscript; 164, identifier:operation; 165, attribute; 166, identifier:i; 167, slice; 168, identifier:i; 169, slice; 170, identifier:np; 171, identifier:setdiff1d; 172, unary_operator; 173, integer:1; 174, integer:1
code: def fill_traversals(traversals, edges, edges_hash=None):
      """
      Convert a traversal of a list of edges into a sequence of
      traversals where every pair of consecutive node indexes
      is an edge in a passed edge list
  
      Parameters
      -------------
      traversals : sequence of (m,) int
         Node indexes of traversals of a graph
      edges : (n, 2) int
         Pairs of connected node indexes
      edges_hash : None, or (n,) int
         Edges sorted along axis 1 then hashed
         using grouping.hashable_rows
  
      Returns
      --------------
      splits : sequence of (p,) int
         Node indexes of connected traversals
      """
      # make sure edges are correct type
      edges = np.asanyarray(edges, dtype=np.int64)
      # make sure edges are sorted
      edges.sort(axis=1)
  
      # if there are no traversals just return edges
      if len(traversals) == 0:
          return edges.copy()
  
      # hash edges for contains checks
      if edges_hash is None:
          edges_hash = grouping.hashable_rows(edges)
  
      splits = []
      for nodes in traversals:
          # split traversals to remove edges
          # that don't actually exist
          splits.extend(split_traversal(
              traversal=nodes,
              edges=edges,
              edges_hash=edges_hash))
      # turn the split traversals back into (n,2) edges
      included = util.vstack_empty([np.column_stack((i[:-1], i[1:]))
                                    for i in splits])
      if len(included) > 0:
          # sort included edges in place
          included.sort(axis=1)
          # make sure any edges not included in split traversals
          # are just added as a length 2 traversal
          splits.extend(grouping.boolean_rows(
              edges,
              included,
              operation=np.setdiff1d))
      else:
          # no edges were included, so our filled traversal
          # is just the original edges copied over
          splits = edges.copy()
  
      return splits