nodes: 0, module; 1, function_definition; 2, function_name:topological_order; 3, parameters; 4, block; 5, identifier:graph; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, expression_statement; 12, while_statement; 13, return_statement; 14, comment:"""Topological sorting by maintaining indegree
  
      :param graph: directed graph in listlist format, cannot be listdict
      :returns: list of vertices in order
      :complexity: `O(|V|+|E|)`
      """; 15, assignment; 16, assignment; 17, identifier:node; 18, identifier:V; 19, comment:# compute indegree; 20, block; 21, assignment; 22, assignment; 23, identifier:Q; 24, block; 25, identifier:order; 26, identifier:V; 27, call; 28, identifier:indeg; 29, list_comprehension; 30, for_statement; 31, identifier:Q; 32, list_comprehension; 33, identifier:order; 34, list; 35, expression_statement; 36, comment:# node without incoming arrows; 37, expression_statement; 38, for_statement; 39, identifier:range; 40, argument_list; 41, integer:0; 42, for_in_clause; 43, identifier:neighbor; 44, subscript; 45, block; 46, identifier:node; 47, for_in_clause; 48, if_clause; 49, assignment; 50, call; 51, identifier:neighbor; 52, subscript; 53, block; 54, call; 55, identifier:_; 56, identifier:V; 57, identifier:graph; 58, identifier:node; 59, expression_statement; 60, identifier:node; 61, identifier:V; 62, comparison_operator:indeg[node] == 0; 63, identifier:node; 64, call; 65, attribute; 66, argument_list; 67, identifier:graph; 68, identifier:node; 69, expression_statement; 70, if_statement; 71, identifier:len; 72, argument_list; 73, augmented_assignment; 74, subscript; 75, integer:0; 76, attribute; 77, argument_list; 78, identifier:order; 79, identifier:append; 80, identifier:node; 81, augmented_assignment; 82, comparison_operator:indeg[neighbor] == 0; 83, block; 84, identifier:graph; 85, subscript; 86, integer:1; 87, identifier:indeg; 88, identifier:node; 89, identifier:Q; 90, identifier:pop; 91, subscript; 92, integer:1; 93, subscript; 94, integer:0; 95, expression_statement; 96, identifier:indeg; 97, identifier:neighbor; 98, identifier:indeg; 99, identifier:neighbor; 100, identifier:indeg; 101, identifier:neighbor; 102, call; 103, attribute; 104, argument_list; 105, identifier:Q; 106, identifier:append; 107, identifier:neighbor
code: def topological_order(graph):
      """Topological sorting by maintaining indegree
  
      :param graph: directed graph in listlist format, cannot be listdict
      :returns: list of vertices in order
      :complexity: `O(|V|+|E|)`
      """
      V = range(len(graph))
      indeg = [0 for _ in V]
      for node in V:            # compute indegree
          for neighbor in graph[node]:
              indeg[neighbor] += 1
      Q = [node for node in V if indeg[node] == 0]
      order = []
      while Q:
          node = Q.pop()        # node without incoming arrows
          order.append(node)
          for neighbor in graph[node]:
              indeg[neighbor] -= 1
              if indeg[neighbor] == 0:
                  Q.append(neighbor)
      return order