parameters: (options, uniqueRoutes, net)
return_statement: return mergeSwitches
docstring: find switches where routes merge and thus conflicts must be solved
docstring_summary: find switches where routes merge and thus conflicts must be solved
docstring_tokens: find switches where routes merge and thus conflicts must be solved
function: def findMergingSwitches(options, uniqueRoutes, net):
      """find switches where routes merge and thus conflicts must be solved"""
      predEdges = defaultdict(set)
      predReversal = set()
      for edges in uniqueRoutes:
          for i, edge in enumerate(edges):
              if i > 0:
                  pred = edges[i - 1]
                  if net.getEdge(edge).getBidi() == net.getEdge(pred):
                      predReversal.add(edge)
                  predEdges[edge].add(pred)
  
      mergeSwitches = set()
      numReversals = 0
      for edge, preds in predEdges.items():
          if len(preds) > 1:
              reversalInfo = ""
              if edge in predReversal:
                  numReversals += 1
                  reversalInfo = " (has reversal)"
              if options.verbose:
                  print("mergingEdge=%s pred=%s%s" % (
                      edge, ','.join(sorted(preds)), reversalInfo))
              mergeSwitches.add(edge)
  
      if numReversals == 0:
          reversalInfo = ""
      else:
          reversalInfo = " (including %s reversal-merges)" % numReversals
      print("processed %s routes across %s edges with %s merging switches%s" % (
          len(uniqueRoutes), len(predEdges), len(mergeSwitches), reversalInfo))
      return mergeSwitches
function_tokens: def findMergingSwitches ( options , uniqueRoutes , net ) : predEdges = defaultdict ( set ) predReversal = set ( ) for edges in uniqueRoutes : for i , edge in enumerate ( edges ) : if i > 0 : pred = edges [ i - 1 ] if net . getEdge ( edge ) . getBidi ( ) == net . getEdge ( pred ) : predReversal . add ( edge ) predEdges [ edge ] . add ( pred ) mergeSwitches = set ( ) numReversals = 0 for edge , preds in predEdges . items ( ) : if len ( preds ) > 1 : reversalInfo = "" if edge in predReversal : numReversals += 1 reversalInfo = " (has reversal)" if options . verbose : print ( "mergingEdge=%s pred=%s%s" % ( edge , ',' . join ( sorted ( preds ) ) , reversalInfo ) ) mergeSwitches . add ( edge ) if numReversals == 0 : reversalInfo = "" else : reversalInfo = " (including %s reversal-merges)" % numReversals print ( "processed %s routes across %s edges with %s merging switches%s" % ( len ( uniqueRoutes ) , len ( predEdges ) , len ( mergeSwitches ) , reversalInfo ) ) return mergeSwitches