
    z	i
                     6    S r SSKJr  SSKJr   " S S\5      rg)zEvaluate how good the layout selection was.

No CX direction is considered.
Saves in `property_set['layout_score']` the sum of distances for each circuit CX.
The lower the number, the better the selection.
Therefore, 0 is a perfect layout selection.
    )AnalysisPass)Targetc                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )Layout2qDistance   a$  Evaluate how good the layout selection was.

Saves in ``property_set['layout_score']`` (or the property name in property_name)
the sum of distances for each circuit CX.
The lower the number, the better the selection. Therefore, 0 is a perfect layout selection.
No CX direction is considered.
c                    > [         TU ]  5         [        U[        5      (       a&  Xl        U R                  R                  5       U l        OSU l        Xl        X l        g)zLayout2qDistance initializer.

Args:
    coupling_map (Union[CouplingMap, Target]): Directed graph represented a coupling map.
    property_name (str): The property name to save the score. Default: layout_score
N)super__init__
isinstancer   targetbuild_coupling_mapcoupling_mapproperty_name)selfr   r   	__class__s      l/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/transpiler/passes/layout/layout_2q_distance.pyr
   Layout2qDistance.__init__"   sJ     	lF++&K $ > > @DDK ,*    c                    U R                   S   nUc  gU R                  b#  [        U R                  R                  5      S:X  a  SU R                   U R                  '   gU R                  R                  5         SnUR                  5       nU R                  R                  nUR                  5        H0  nXFR                  S      nXFR                  S      nX5Xx4   S-
  -  nM2     X0R                   U R                  '   g)zV
Run the Layout2qDistance pass on `dag`.
Args:
    dag (DAGCircuit): DAG to evaluate.
layoutNr      )
property_setr   lengraphr   compute_distance_matrixget_virtual_bitsdistance_matrixtwo_qubit_opsqargs)	r   dagr   sum_distancevirtual_physical_mapdist_matrixgatephysical_q0physical_q1s	            r   runLayout2qDistance.run2   s     ""8,>$D,=,=,C,C(D(I45Dd001113%668''77%%'D.zz!}=K.zz!}=K(@AAEEL	 ( 1=$,,-r   )r   r   r   )layout_score)	__name__
__module____qualname____firstlineno____doc__r
   r'   __static_attributes____classcell__)r   s   @r   r   r      s    + = =r   r   N)r.   qiskit.transpiler.basepassesr   qiskit.transpiler.targetr   r    r   r   <module>r4      s    6 +4=| 4=r   