parameters: (layers)
docstring: Topologically ordered traversal of layer graph.
  
      All layers that are connected to `layers` will be traversed. The
      layer graph is assumed to be acyclic. No checks are made for
      cycles and strange things may happen if one exists.
  
      Args:
          layers (Layer or Iterator of Layer): Node(s) in layer graph.
  
      Yields:
          Layer: Node in layer graph, in a topological order.
docstring_summary: Topologically ordered traversal of layer graph.
docstring_tokens: Topologically ordered traversal of layer graph .
function: def traverse_layer_graph(layers):
      """Topologically ordered traversal of layer graph.
  
      All layers that are connected to `layers` will be traversed. The
      layer graph is assumed to be acyclic. No checks are made for
      cycles and strange things may happen if one exists.
  
      Args:
          layers (Layer or Iterator of Layer): Node(s) in layer graph.
  
      Yields:
          Layer: Node in layer graph, in a topological order.
  
      """
  
      # DFS to find root nodes in layer graph
      roots = []
      visited = set()
      stack = list(make_iterable(layers))
      while stack:
          l = stack.pop()
          if l not in visited:
              visited.add(l)
              stack.extend(l.parents)
              stack.extend(l.children)
              if not l.parents:
                  roots.append(l)
  
      # DFS to traverse layer graph in topological order
      visited = set()
      stack = roots
      while stack:
          l = stack.pop()
          if (l not in visited
              and all([(p in visited) for p in l.parents])):
              visited.add(l)
              stack.extend(l.children)
              yield l
function_tokens: def traverse_layer_graph ( layers ) : # DFS to find root nodes in layer graph roots = [ ] visited = set ( ) stack = list ( make_iterable ( layers ) ) while stack : l = stack . pop ( ) if l not in visited : visited . add ( l ) stack . extend ( l . parents ) stack . extend ( l . children ) if not l . parents : roots . append ( l ) # DFS to traverse layer graph in topological order visited = set ( ) stack = roots while stack : l = stack . pop ( ) if ( l not in visited and all ( [ ( p in visited ) for p in l . parents ] ) ) : visited . add ( l ) stack . extend ( l . children ) yield l