parameters: (self)
docstring: Find the loops defined by the graph's back edges.
docstring_summary: Find the loops defined by the graph's back edges.
docstring_tokens: Find the loops defined by the graph s back edges .
function: def _find_loops(self):
          """
          Find the loops defined by the graph's back edges.
          """
          bodies = {}
          for src, dest in self._back_edges:
              # The destination of the back edge is the loop header
              header = dest
              # Build up the loop body from the back edge's source node,
              # up to the source header.
              body = set([header])
              queue = [src]
              while queue:
                  n = queue.pop()
                  if n not in body:
                      body.add(n)
                      queue.extend(self._preds[n])
              # There can be several back edges to a given loop header;
              # if so, merge the resulting body fragments.
              if header in bodies:
                  bodies[header].update(body)
              else:
                  bodies[header] = body
  
          # Create a Loop object for each header.
          loops = {}
          for header, body in bodies.items():
              entries = set()
              exits = set()
              for n in body:
                  entries.update(self._preds[n] - body)
                  exits.update(self._succs[n] - body)
              loop = Loop(header=header, body=body, entries=entries, exits=exits)
              loops[header] = loop
          self._loops = loops
  
          # Compute the loops to which each node belongs.
          in_loops = dict((n, []) for n in self._nodes)
          # Sort loops from longest to shortest
          # This ensures that outer loops will come before inner loops
          for loop in sorted(loops.values(), key=lambda loop: len(loop.body)):
              for n in loop.body:
                  in_loops[n].append(loop.header)
          self._in_loops = in_loops
function_tokens: def _find_loops ( self ) : bodies = { } for src , dest in self . _back_edges : # The destination of the back edge is the loop header header = dest # Build up the loop body from the back edge's source node, # up to the source header. body = set ( [ header ] ) queue = [ src ] while queue : n = queue . pop ( ) if n not in body : body . add ( n ) queue . extend ( self . _preds [ n ] ) # There can be several back edges to a given loop header; # if so, merge the resulting body fragments. if header in bodies : bodies [ header ] . update ( body ) else : bodies [ header ] = body # Create a Loop object for each header. loops = { } for header , body in bodies . items ( ) : entries = set ( ) exits = set ( ) for n in body : entries . update ( self . _preds [ n ] - body ) exits . update ( self . _succs [ n ] - body ) loop = Loop ( header = header , body = body , entries = entries , exits = exits ) loops [ header ] = loop self . _loops = loops # Compute the loops to which each node belongs. in_loops = dict ( ( n , [ ] ) for n in self . _nodes ) # Sort loops from longest to shortest # This ensures that outer loops will come before inner loops for loop in sorted ( loops . values ( ) , key = lambda loop : len ( loop . body ) ) : for n in loop . body : in_loops [ n ] . append ( loop . header ) self . _in_loops = in_loops