code: def topological_sort(G, nbunch):
      # nonrecursive version
      seen = set()
      order = []
      explored = set()
  
      if nbunch is None:
          nbunch = G.nodes()
      for v in nbunch:  # process all vertices in G
          if v in explored:
              continue
          fringe = [v]  # nodes yet to look at
          while fringe:
              w = fringe[-1]  # depth first search
              if w in explored:  # already looked down this branch
                  fringe.pop()
                  continue
              seen.add(w)  # mark as seen
              # Check successors for cycles and for new nodes
              new_nodes = []
              for n in G[w]:
                  if n not in explored:
                      if n in seen:  # CYCLE !!
                          raise graph.Unfeasible(
                              "Graph contains a cycle at %s." % n
                          )
                      new_nodes.append(n)
              if new_nodes:  # Add new_nodes to fringe
                  fringe.extend(new_nodes)
              else:  # No new nodes so w is fully explored
                  explored.add(w)
                  order.append(w)
                  fringe.pop()  # done considering this node
      return list(reversed(order))
  
file_path: pythran/pythran/types/reorder.py
imports: import gast
  from pythran.analyses import OrderedGlobalDeclarations
  from pythran.passmanager import Transformation
  from pythran.syntax import PythranSyntaxError
  from pythran.types.type_dependencies import TypeDependencies
  import pythran.graph
label_desc: Use image node_id 1 for calling a global function with example usage: topological_sort(G, nbunch) and returns: list