# qiskit.transpiler.CouplingMap¶

class CouplingMap(couplinglist=None, description=None)[código fonte]

Directed graph specifying fixed coupling.

Nodes correspond to physical qubits (integers) and directed edges correspond to permitted CNOT gates

Create coupling graph. By default, the generated coupling has no nodes.

Parâmetros
• couplinglist (list or None) – An initial coupling graph, specified as an adjacency list containing couplings, e.g. [[0,1], [0,2], [1,2]].

• description (str) – A string to describe the coupling map.

__init__(couplinglist=None, description=None)[código fonte]

Create coupling graph. By default, the generated coupling has no nodes.

Parâmetros
• couplinglist (list or None) – An initial coupling graph, specified as an adjacency list containing couplings, e.g. [[0,1], [0,2], [1,2]].

• description (str) – A string to describe the coupling map.

Methods

 __init__([couplinglist, description]) Create coupling graph. add_edge(src, dst) Add directed edge to coupling graph. add_physical_qubit(physical_qubit) Add a physical qubit to the coupling graph as a node. distance(physical_qubit1, physical_qubit2) Returns the undirected distance between physical_qubit1 and physical_qubit2. Draws the coupling map. from_full(num_qubits[, bidirectional]) Return a fully connected coupling map on n qubits. from_grid(num_rows, num_columns[, bidirectional]) Return qubits connected on a grid of num_rows x num_columns. from_line(num_qubits[, bidirectional]) Return a fully connected coupling map on n qubits. from_ring(num_qubits[, bidirectional]) Return a fully connected coupling map on n qubits. Gets the list of edges in the coupling graph. Test if the graph is connected. Return a set of qubits in the largest connected component. Convert uni-directional edges into bi-directional. neighbors(physical_qubit) Return the nearest neighbors of a physical qubit. reduce(mapping) Returns a reduced coupling map that corresponds to the subgraph of qubits selected in the mapping. shortest_undirected_path(physical_qubit1, …) Returns the shortest undirected path between physical_qubit1 and physical_qubit2. Return the number of physical qubits in this graph. subgraph(nodelist) Return a CouplingMap object for a subgraph of self.

Attributes

 distance_matrix Return the distance matrix for the coupling map. is_symmetric Test if the graph is symmetric. physical_qubits Returns a sorted list of physical_qubits
add_edge(src, dst)[código fonte]

Add directed edge to coupling graph.

src (int): source physical qubit dst (int): destination physical qubit

add_physical_qubit(physical_qubit)[código fonte]

Add a physical qubit to the coupling graph as a node.

physical_qubit (int): An integer representing a physical qubit.

Levanta

CouplingError – if trying to add duplicate qubit

distance(physical_qubit1, physical_qubit2)[código fonte]

Returns the undirected distance between physical_qubit1 and physical_qubit2.

Parâmetros
• physical_qubit1 (int) – A physical qubit

• physical_qubit2 (int) – Another physical qubit

Retorna

The undirected distance

Tipo de retorno

int

Levanta

CouplingError – if the qubits do not exist in the CouplingMap

property distance_matrix

Return the distance matrix for the coupling map.

draw()[código fonte]

Draws the coupling map.

This function needs pydot, which in turn needs Graphviz to be installed. Additionally, pillow will need to be installed.

Retorna

Drawn coupling map.

Tipo de retorno

PIL.Image

Levanta

ImportError – when pydot or pillow are not installed.

classmethod from_full(num_qubits, bidirectional=True)[código fonte]

Return a fully connected coupling map on n qubits.

classmethod from_grid(num_rows, num_columns, bidirectional=True)[código fonte]

Return qubits connected on a grid of num_rows x num_columns.

classmethod from_line(num_qubits, bidirectional=True)[código fonte]

Return a fully connected coupling map on n qubits.

classmethod from_ring(num_qubits, bidirectional=True)[código fonte]

Return a fully connected coupling map on n qubits.

get_edges()[código fonte]

Gets the list of edges in the coupling graph.

Retorna

Each edge is a pair of physical qubits.

Tipo de retorno

Tuple(int,int)

is_connected()[código fonte]

Test if the graph is connected.

Return True if connected, False otherwise

property is_symmetric

Test if the graph is symmetric.

Return True if symmetric, False otherwise

largest_connected_component()[código fonte]

Return a set of qubits in the largest connected component.

make_symmetric()[código fonte]

Convert uni-directional edges into bi-directional.

neighbors(physical_qubit)[código fonte]

Return the nearest neighbors of a physical qubit.

Directionality matters, i.e. a neighbor must be reachable by going one hop in the direction of an edge.

property physical_qubits

Returns a sorted list of physical_qubits

reduce(mapping)[código fonte]

Returns a reduced coupling map that corresponds to the subgraph of qubits selected in the mapping.

Parâmetros

mapping (list) – A mapping of reduced qubits to device qubits.

Retorna

A reduced coupling_map for the selected qubits.

Tipo de retorno

CouplingMap

Levanta

CouplingError – Reduced coupling map must be connected.

shortest_undirected_path(physical_qubit1, physical_qubit2)[código fonte]

Returns the shortest undirected path between physical_qubit1 and physical_qubit2.

Parâmetros
• physical_qubit1 (int) – A physical qubit

• physical_qubit2 (int) – Another physical qubit

Retorna

The shortest undirected path

Tipo de retorno

List

Levanta

CouplingError – When there is no path between physical_qubit1, physical_qubit2.

size()[código fonte]

Return the number of physical qubits in this graph.

subgraph(nodelist)[código fonte]

Return a CouplingMap object for a subgraph of self.

nodelist (list): list of integer node labels