Ejemplo n.º 1
0
def load_coupling_graph(coupling_graph_file_path, num_qubits):
    coupling_graph = CouplingMap()
    for i in range(num_qubits):
        coupling_graph.add_physical_qubit(i)

    with open(coupling_graph_file_path, newline='') as coupling_graph_file:
        csv_reader = csv.reader(coupling_graph_file)
        for source_qubit, destination_qubit in csv_reader:
            coupling_graph.add_edge(int(source_qubit), int(destination_qubit))
    return coupling_graph
Ejemplo n.º 2
0
 def test_distance_error(self):
     """Test distance between unconnected physical_qubits."""
     graph = CouplingMap()
     graph.add_physical_qubit(0)
     graph.add_physical_qubit(1)
     self.assertRaises(CouplingError, graph.distance, 0, 1)
Ejemplo n.º 3
0
 def test_add_physical_qubits(self):
     coupling = CouplingMap()
     self.assertEqual("", str(coupling))
     coupling.add_physical_qubit(0)
     self.assertEqual([0], coupling.physical_qubits)
     self.assertEqual("", str(coupling))