def initial_mapping(self, circuit: cirq.AbstractCircuit) -> dict[cirq.Qid, cirq.Qid]:
        """Maps disjoint lines of logical qubits onto lines of physical qubits.

        Args:
            circuit: the input circuit with logical qubits

        Returns:
            a dictionary that maps logical qubits in the circuit (keys) to physical qubits on the
            device (values).
        """
        mapped_physicals: set[cirq.Qid] = set()
        qubit_map: dict[cirq.Qid, cirq.Qid] = {}
        circuit_graph, partners = self._make_circuit_graph(circuit)

        def next_physical(
            current_physical: cirq.Qid, partner: cirq.Qid, isolated: bool = False
        ) -> cirq.Qid:
            # Handle the first physical qubit getting mapped.
            if current_physical not in mapped_physicals:
                return current_physical
            # Greedily map to highest degree neighbor that is available
            if not isolated:
                sorted_neighbors = sorted(
                    self.device_graph.neighbors(current_physical),
                    key=lambda x: self.device_graph.degree(x),
                    reverse=True,
                )
                for neighbor in sorted_neighbors:
                    if neighbor not in mapped_physicals:
                        return neighbor
                # If cannot map onto one long line of physical qubits, then break down into multiple
                # small lines by finding nearest available qubit to the physical center
            return self._closest_unmapped_qubit(partner, mapped_physicals)

        pq = self.center
        for logical_line in circuit_graph:
            for lq in logical_line:
                is_isolated = len(logical_line) == 1
                partner = (
                    qubit_map[partners[lq]] if (lq in partners and is_isolated) else self.center
                )
                pq = next_physical(pq, partner, isolated=is_isolated)
                mapped_physicals.add(pq)
                qubit_map[lq] = pq

        return qubit_map
Maps disjoint lines of logical qubits onto lines of physical qubits.

        Args:
            circuit: the input circuit with logical qubits

        Returns:
            a dictionary that maps logical qubits in the circuit (keys) to physical qubits on the
            device (values).
        
cirq-core/cirq/transformers/routing/line_initial_mapper.py