qiskit.transpiler.CouplingMap.connected_components¶
- CouplingMap.connected_components()[source]¶
Separate a
CouplingMap
into subgraphCouplingMap
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 entireCouplingMap
.This method will return a list of
CouplingMap
objects, one for each connected component in thisCouplingMap
. The data payload of each node in thegraph
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 combinedCouplingMap
. 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 index0
in the second component is qubit 3 in the original cmap.- Returns
- 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.
- A list of
- Return type
list