Circuit Diagrams
Quantum algorithms are written and reasoned about as circuit diagrams — a standard graphical notation that makes the flow of computation immediately visible. Before building more complex programs, it is worth learning to read these diagrams fluently.
Wires carry qubits through time
Each horizontal line in a circuit diagram represents one qubit. Time flows from left to right: the left end of a wire is the qubit's initial state (almost always ), and the right end is the qubit just before it is either measured or discarded.
Wires are not wires in the electrical sense — no current flows. They are a bookkeeping device that tracks which qubit a gate acts on. A single-qubit system has one wire; an -qubit system has wires, typically labelled from top to bottom.
Gates are boxes on wires
An operation applied to a qubit appears as a labelled box sitting on the corresponding wire. A single-qubit gate straddles exactly one wire. For example, the Hadamard gate is drawn as a box containing the letter , and the Pauli gate (a quantum NOT) appears as a box labelled .
Two-qubit gates span two wires. The CNOT (controlled-NOT) uses a filled circle on the control wire and an symbol on the target wire, connected by a vertical line. The convention immediately tells you which qubit controls the operation and which qubit gets flipped.
Reading time order
Gates are applied in the order they appear from left to right. A circuit that first applies to qubit 0 and then applies a CNOT (qubit 0 as control, qubit 1 as target) is written with the box to the left of the CNOT. If two gates act on different wires and share no qubit, they can be drawn at the same horizontal position — they commute in the sense that neither depends on the other, and the diagram makes that independence visible at a glance.
Measurement
Measurement is shown by a special symbol at the right end of a wire — often a box with a dial, or simply the letter . A double line emerging from a measurement box represents a classical bit: the deterministic 0 or 1 that the measurement records. In many diagrams, classical wires are drawn thicker or with two parallel lines to distinguish them from quantum wires.
Putting it together
A two-qubit Bell-state circuit is a useful example to practice reading:
- Wire starts in . A box labelled appears on — apply the Hadamard.
- Immediately to the right, a CNOT spans both wires: the filled circle sits on (control) and sits on (target).
- Both wires then terminate at measurement symbols.
Reading left to right, you reconstruct the algorithm: first create superposition on , then
entangle the two qubits, then measure. The diagram encodes exactly the same information as the code
c.h(0); c.cx(0, 1); c.measure(); but in a form that highlights structure rather than syntax.
With this reading skill in hand, you are ready to work through circuits of any size — the rest of this module builds the vocabulary of gates and idioms that fill those boxes.
Sign in on the full site to ask questions and join the discussion.