qiskit/transpiler/passes/mapping/check_cnot_direction.py
def run(self, dag):
        """
        If `dag` is mapped and the direction is correct the property
        `is_direction_mapped` is set to True (or to False otherwise).

        Args:
            dag (DAGCircuit): DAG to check.
        """
        if self.layout is None:
            if self.property_set["layout"]:
                self.layout = self.property_set["layout"]
            else:
                self.layout = Layout.generate_trivial_layout(*dag.qregs.values())

        self.property_set['is_direction_mapped'] = True
        edges = self.coupling_map.get_edges()

        for gate in dag.twoQ_gates():
            physical_q0 = self.layout[gate.qargs[0]]
            physical_q1 = self.layout[gate.qargs[1]]

            if isinstance(gate.op, (CXBase, CnotGate)) and (
                    physical_q0, physical_q1) not in edges:
                self.property_set['is_direction_mapped'] = False
                return
def run(self, dag):
        """
        If `dag` is mapped and the direction is correct the property
        `is_direction_mapped` is set to True (or to False otherwise).

        Args:
            dag (DAGCircuit): DAG to check.
        """
        if self.layout is None:
            if self.property_set["layout"]:
                self.layout = self.property_set["layout"]
            else:
                self.layout = Layout.generate_trivial_layout(*dag.qregs.values())

        self.property_set['is_direction_mapped'] = True
        edges = self.coupling_map.get_edges()

        for gate in dag.twoQ_gates():
            physical_q0 = self.layout[gate.qargs[0]]
            physical_q1 = self.layout[gate.qargs[1]]

            if isinstance(gate.op, (CXBase, CnotGate)) and (
                    physical_q0, physical_q1) not in edges:
                self.property_set['is_direction_mapped'] = False
                return
def run ( self , dag ) : if self . layout is None : if self . property_set [ "layout" ] : self . layout = self . property_set [ "layout" ] else : self . layout = Layout . generate_trivial_layout ( * dag . qregs . values ( ) ) self . property_set [ 'is_direction_mapped' ] = True edges = self . coupling_map . get_edges ( ) for gate in dag . twoQ_gates ( ) : physical_q0 = self . layout [ gate . qargs [ 0 ] ] physical_q1 = self . layout [ gate . qargs [ 1 ] ] if isinstance ( gate . op , ( CXBase , CnotGate ) ) and ( physical_q0 , physical_q1 ) not in edges : self . property_set [ 'is_direction_mapped' ] = False return
If `dag` is mapped and the direction is correct the property
        `is_direction_mapped` is set to True (or to False otherwise).

        Args:
            dag (DAGCircuit): DAG to check.
If dag is mapped and the direction is correct the property is_direction_mapped is set to True ( or to False otherwise ) .