def __init__(self, device_graph: nx.Graph, initial_mapping: dict[cirq.Qid, cirq.Qid]) -> None:
        """Initializes MappingManager.

        Args:
            device_graph: connectivity graph of qubits in the hardware device.
            initial_mapping: the initial mapping of logical (keys) to physical qubits (values).
        """
        # Map both logical and physical qubits to integers.
        self._logical_qid_to_int = {q: i for i, q in enumerate(sorted(initial_mapping.keys()))}
        self._int_to_logical_qid = sorted(
            self._logical_qid_to_int.keys(), key=lambda x: self._logical_qid_to_int[x]
        )
        self._physical_qid_to_int = {q: i for i, q in enumerate(sorted(initial_mapping.values()))}
        self._int_to_physical_qid = sorted(
            self._physical_qid_to_int.keys(), key=lambda x: self._physical_qid_to_int[x]
        )
        logical_qubits, physical_qubits = (
            zip(*[(k, v) for k, v in initial_mapping.items()]) if initial_mapping else ([], [])
        )
        num_qubits = len(logical_qubits)
        self._logical_to_physical = np.asarray(
            [
                self._physical_qid_to_int[physical_qubits[i]]
                for i in sorted(
                    range(num_qubits), key=lambda x: self._logical_qid_to_int[logical_qubits[x]]
                )
            ]
        )
        self._physical_to_logical = np.asarray(
            [
                self._logical_qid_to_int[logical_qubits[i]]
                for i in sorted(
                    range(num_qubits), key=lambda x: self._physical_qid_to_int[physical_qubits[x]]
                )
            ]
        )
        # Construct the induced subgraph (on integers) and corresponding distance matrix.
        self._induced_subgraph_int = nx.relabel_nodes(
            nx.induced_subgraph(device_graph, initial_mapping.values()),
            {q: self._physical_qid_to_int[q] for q in initial_mapping.values()},
        )
        # Compute floyd warshall dictionary.
        self._predecessors, self._distances = nx.floyd_warshall_predecessor_and_distance(
            self._induced_subgraph_int
        )
Initializes MappingManager.

        Args:
            device_graph: connectivity graph of qubits in the hardware device.
            initial_mapping: the initial mapping of logical (keys) to physical qubits (values).
        
cirq-core/cirq/transformers/routing/mapping_manager.py