French
Languages
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

qiskit.transpiler.CouplingMap.connected_components

CouplingMap.connected_components()[source]

Separate a CouplingMap into subgraph CouplingMap for each connected component.

The connected components of a CouplingMap are the subgraphs that are not part of any larger subgraph. For example, if you had a coupling map that looked like:

0 --> 1   4 --> 5 ---> 6 --> 7
|     |
|     |
V     V
2 --> 3

then the connected components of that graph are the subgraphs:

0 --> 1
|     |
|     |
V     V
2 --> 3

and:

4 --> 5 ---> 6 --> 7

For a connected CouplingMap object there is only a single connected component, the entire CouplingMap.

This method will return a list of CouplingMap objects, one for each connected component in this CouplingMap. The data payload of each node in the graph attribute will contain the qubit number in the original graph. This will enables mapping the qubit index in a component subgraph to the original qubit in the combined CouplingMap. For example:

from qiskit.transpiler import CouplingMap

cmap = CouplingMap([[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]])
component_cmaps = cmap.connected_components()
print(component_cmaps[1].graph[0])

will print 3 as index 0 in the second component is qubit 3 in the original cmap.

Renvoie

A list of CouplingMap objects for each connected

components. The order of this list is deterministic but implementation specific and shouldn’t be relied upon as part of the API.

Type renvoyé

list