code: def topological_order(graph):
      V = range(len(graph))
      indeg = [0 for _ in V]
      for node in V:
          for neighbor in graph[node]:
              indeg[neighbor] += 1
      Q = [node for node in V if indeg[node] == 0]
      order = []
      while Q:
          node = Q.pop()
          order.append(node)
          for neighbor in graph[node]:
              indeg[neighbor] -= 1
              if indeg[neighbor] == 0:
                  Q.append(neighbor)
      return order