def _route(
        cls,
        mm: mapping_manager.MappingManager,
        two_qubit_ops: list[list[cirq.Operation]],
        single_qubit_ops: list[list[cirq.Operation]],
        lookahead_radius: int,
        tag_inserted_swaps: bool = False,
    ) -> list[list[cirq.Operation]]:
        """Main routing procedure that inserts necessary swaps on the given timesteps.

        The i'th element of the returned list corresponds to the routed operatiosn in the i'th
        timestep.

        Args:
          two_qubit_ops: the circuit's two-qubit gates factored into timesteps as defined by the
            paper.
          single_qubit_ops: the circuit's single-qubit gates factored into timesteps as defined by
            the paper.
          lookahead_radius: the maximum number of times the cost function can be iterated for
            convergence.
        tag_inserted_swaps: whether or not a RoutingSwapTag should be attched to inserted swap
            operations.

        Returns:
            a list of lists corresponding to timesteps of the routed circuit.
        """
        two_qubit_ops_ints: list[list[QidIntPair]] = [
            [
                (mm.logical_qid_to_int[op.qubits[0]], mm.logical_qid_to_int[op.qubits[1]])
                for op in timestep_ops
            ]
            for timestep_ops in two_qubit_ops
        ]
        routed_ops: list[list[cirq.Operation]] = []

        def process_executable_two_qubit_ops(timestep: int) -> int:
            unexecutable_ops: list[cirq.Operation] = []
            unexecutable_ops_ints: list[QidIntPair] = []
            for op, op_ints in zip(two_qubit_ops[timestep], two_qubit_ops_ints[timestep]):
                if mm.is_adjacent(*op_ints):
                    routed_ops[timestep].append(mm.mapped_op(op))
                else:
                    unexecutable_ops.append(op)
                    unexecutable_ops_ints.append(op_ints)
            two_qubit_ops[timestep] = unexecutable_ops
            two_qubit_ops_ints[timestep] = unexecutable_ops_ints
            return len(unexecutable_ops)

        strats = [cls._choose_single_swap, cls._choose_pair_of_swaps]

        for timestep in range(len(two_qubit_ops)):
            # Add single-qubit ops with qubits given by the current mapping.
            routed_ops.append([mm.mapped_op(op) for op in single_qubit_ops[timestep]])

            # swaps applied in the current timestep thus far. This ensures the same swaps
            # don't get executed twice in the same timestep.
            seen: set[tuple[QidIntPair, ...]] = set()

            while process_executable_two_qubit_ops(timestep):
                chosen_swaps: tuple[QidIntPair, ...] | None = None
                for strat in strats:
                    chosen_swaps = strat(mm, two_qubit_ops_ints, timestep, lookahead_radius)
                    if chosen_swaps is not None:
                        break

                if chosen_swaps is None or chosen_swaps in seen:
                    chosen_swaps = cls._brute_force_strategy(mm, two_qubit_ops_ints, timestep)
                else:
                    seen.add(chosen_swaps)

                for swap in chosen_swaps:
                    inserted_swap = mm.mapped_op(
                        ops.SWAP(mm.int_to_logical_qid[swap[0]], mm.int_to_logical_qid[swap[1]])
                    )
                    if tag_inserted_swaps:
                        inserted_swap = inserted_swap.with_tags(ops.RoutingSwapTag())
                    routed_ops[timestep].append(inserted_swap)
                    mm.apply_swap(*swap)

        return routed_ops
Main routing procedure that inserts necessary swaps on the given timesteps.

        The i'th element of the returned list corresponds to the routed operatiosn in the i'th
        timestep.

        Args:
          two_qubit_ops: the circuit's two-qubit gates factored into timesteps as defined by the
            paper.
          single_qubit_ops: the circuit's single-qubit gates factored into timesteps as defined by
            the paper.
          lookahead_radius: the maximum number of times the cost function can be iterated for
            convergence.
        tag_inserted_swaps: whether or not a RoutingSwapTag should be attched to inserted swap
            operations.

        Returns:
            a list of lists corresponding to timesteps of the routed circuit.
        
cirq-core/cirq/transformers/routing/route_circuit_cqc.py