qiskit/transpiler/passes/mapping/noise_adaptive_layout.py
def _create_program_graph(self, dag):
        """
        Program graph has virtual qubits as nodes.
        Two nodes have an edge if the corresponding virtual qubits
        participate in a 2-qubit gate. The edge is weighted by the
        number of CNOTs between the pair.
        """
        idx = 0
        for q in dag.qubits():
            self.qarg_to_id[q[0].name + str(q[1])] = idx
            idx += 1
        for gate in dag.twoQ_gates():
            qid1 = self._qarg_to_id(gate.qargs[0])
            qid2 = self._qarg_to_id(gate.qargs[1])
            min_q = min(qid1, qid2)
            max_q = max(qid1, qid2)
            edge_weight = 1
            if self.prog_graph.has_edge(min_q, max_q):
                edge_weight = self.prog_graph[min_q][max_q]['weight'] + 1
            self.prog_graph.add_edge(min_q, max_q, weight=edge_weight)
        return idx
def _create_program_graph(self, dag):
        """
        Program graph has virtual qubits as nodes.
        Two nodes have an edge if the corresponding virtual qubits
        participate in a 2-qubit gate. The edge is weighted by the
        number of CNOTs between the pair.
        """
        idx = 0
        for q in dag.qubits():
            self.qarg_to_id[q[0].name + str(q[1])] = idx
            idx += 1
        for gate in dag.twoQ_gates():
            qid1 = self._qarg_to_id(gate.qargs[0])
            qid2 = self._qarg_to_id(gate.qargs[1])
            min_q = min(qid1, qid2)
            max_q = max(qid1, qid2)
            edge_weight = 1
            if self.prog_graph.has_edge(min_q, max_q):
                edge_weight = self.prog_graph[min_q][max_q]['weight'] + 1
            self.prog_graph.add_edge(min_q, max_q, weight=edge_weight)
        return idx
def _create_program_graph ( self , dag ) : idx = 0 for q in dag . qubits ( ) : self . qarg_to_id [ q [ 0 ] . name + str ( q [ 1 ] ) ] = idx idx += 1 for gate in dag . twoQ_gates ( ) : qid1 = self . _qarg_to_id ( gate . qargs [ 0 ] ) qid2 = self . _qarg_to_id ( gate . qargs [ 1 ] ) min_q = min ( qid1 , qid2 ) max_q = max ( qid1 , qid2 ) edge_weight = 1 if self . prog_graph . has_edge ( min_q , max_q ) : edge_weight = self . prog_graph [ min_q ] [ max_q ] [ 'weight' ] + 1 self . prog_graph . add_edge ( min_q , max_q , weight = edge_weight ) return idx
Program graph has virtual qubits as nodes.
        Two nodes have an edge if the corresponding virtual qubits
        participate in a 2-qubit gate. The edge is weighted by the
        number of CNOTs between the pair.
Program graph has virtual qubits as nodes . Two nodes have an edge if the corresponding virtual qubits participate in a 2 - qubit gate . The edge is weighted by the number of CNOTs between the pair .