nodes: 0, module; 1, function_definition; 2, function_name:topological_order_dfs; 3, parameters; 4, block; 5, identifier:graph; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:"""Topological sorting by depth first search
  
      :param graph: directed graph in listlist format, cannot be listdict
      :returns: list of vertices in order
      :complexity: `O(|V|+|E|)`
      """; 13, assignment; 14, assignment; 15, assignment; 16, identifier:start; 17, call; 18, block; 19, subscript; 20, identifier:n; 21, call; 22, identifier:order; 23, list; 24, identifier:times_seen; 25, binary_operator:[-1] * n; 26, identifier:range; 27, argument_list; 28, if_statement; 29, identifier:order; 30, slice; 31, identifier:len; 32, argument_list; 33, list; 34, identifier:n; 35, identifier:n; 36, comparison_operator:times_seen[start] == -1; 37, block; 38, unary_operator; 39, identifier:graph; 40, unary_operator; 41, subscript; 42, unary_operator; 43, expression_statement; 44, expression_statement; 45, while_statement; 46, integer:1; 47, integer:1; 48, identifier:times_seen; 49, identifier:start; 50, integer:1; 51, assignment; 52, assignment; 53, identifier:to_visit; 54, block; 55, subscript; 56, integer:0; 57, identifier:to_visit; 58, list; 59, expression_statement; 60, expression_statement; 61, if_statement; 62, identifier:times_seen; 63, identifier:start; 64, identifier:start; 65, assignment; 66, assignment; 67, comparison_operator:times_seen[node] == len(children); 68, block; 69, else_clause; 70, identifier:node; 71, subscript; 72, identifier:children; 73, subscript; 74, subscript; 75, call; 76, expression_statement; 77, expression_statement; 78, block; 79, identifier:to_visit; 80, unary_operator; 81, identifier:graph; 82, identifier:node; 83, identifier:times_seen; 84, identifier:node; 85, identifier:len; 86, argument_list; 87, call; 88, call; 89, expression_statement; 90, expression_statement; 91, if_statement; 92, integer:1; 93, identifier:children; 94, attribute; 95, argument_list; 96, attribute; 97, argument_list; 98, assignment; 99, augmented_assignment; 100, comparison_operator:times_seen[child] == -1; 101, block; 102, identifier:to_visit; 103, identifier:pop; 104, identifier:order; 105, identifier:append; 106, identifier:node; 107, identifier:child; 108, subscript; 109, subscript; 110, integer:1; 111, subscript; 112, unary_operator; 113, expression_statement; 114, expression_statement; 115, identifier:children; 116, subscript; 117, identifier:times_seen; 118, identifier:node; 119, identifier:times_seen; 120, identifier:child; 121, integer:1; 122, assignment; 123, call; 124, identifier:times_seen; 125, identifier:node; 126, subscript; 127, integer:0; 128, attribute; 129, argument_list; 130, identifier:times_seen; 131, identifier:child; 132, identifier:to_visit; 133, identifier:append; 134, identifier:child
code: def topological_order_dfs(graph):
      """Topological sorting by depth first search
  
      :param graph: directed graph in listlist format, cannot be listdict
      :returns: list of vertices in order
      :complexity: `O(|V|+|E|)`
      """
      n = len(graph)
      order = []
      times_seen = [-1] * n
      for start in range(n):
          if times_seen[start] == -1:
              times_seen[start] = 0
              to_visit = [start]
              while to_visit:
                  node = to_visit[-1]
                  children = graph[node]
                  if times_seen[node] == len(children):
                      to_visit.pop()
                      order.append(node)
                  else:
                      child = children[times_seen[node]]
                      times_seen[node] += 1
                      if times_seen[child] == -1:
                          times_seen[child] = 0
                          to_visit.append(child)
      return order[::-1]