Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.

Home Page:https://www.ibm.com/quantum/qiskit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

plot_circuit_layout colors edges incorrectly

kevinsung opened this issue · comments

Environment

  • Qiskit version:
  • Python version:
  • Operating system:

What is happening?

I believe the intent is for the black edges to connect the black qubits.

How can we reproduce the issue?

from qiskit.circuit.library import EfficientSU2
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.transpiler import CouplingMap
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit.visualization import plot_circuit_layout

# Construct circuit
n_qubits = 10
circuit = EfficientSU2(n_qubits, entanglement="pairwise")

# Initialize simulator backend
coupling_map = CouplingMap.from_heavy_hex(3)
backend = GenericBackendV2(
    coupling_map.size(),
    basis_gates=["ecr", "id", "rz", "sx", "x"],
    coupling_map=coupling_map,
    seed=1234
)

# Transpile circuit
pass_manager = generate_preset_pass_manager(
    optimization_level=3, backend=backend, seed_transpiler=1234
)
isa_circuit = pass_manager.run(circuit)

plot_circuit_layout(isa_circuit, backend, view="physical")

image

What should happen?

Black edges should connect black qubits.

Any suggestions?

No response

The bug is caused by this line:

graph = graph.to_undirected(multigraph=False)

It creates a new graph, and the edge order of the new graph no longer matches the order assumed in the list of edge colors passed as line_color.