Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot_circuit_layout colors edges incorrectly #12354

Closed
kevinsung opened this issue May 6, 2024 · 1 comment · Fixed by #12369
Closed

plot_circuit_layout colors edges incorrectly #12354

kevinsung opened this issue May 6, 2024 · 1 comment · Fixed by #12369
Labels
bug Something isn't working

Comments

@kevinsung
Copy link
Contributor

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

@kevinsung kevinsung added the bug Something isn't working label May 6, 2024
@kevinsung
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant