# GraphState¶

class GraphState(adjacency_matrix)[source]

Circuit to prepare a graph state.

Given a graph G = (V, E), with the set of vertices V and the set of edges E, the corresponding graph state is defined as

$|G\rangle = \prod_{(a,b) \in E} CZ_{(a,b)} {|+\rangle}^{\otimes V}$

Such a state can be prepared by first preparing all qubits in the $$+$$ state, then applying a $$CZ$$ gate for each corresponding graph edge.

Graph state preparation circuits are Clifford circuits, and thus easy to simulate classically. However, by adding a layer of measurements in a product basis at the end, there is evidence that the circuit becomes hard to simulate .

Reference Circuit:

References:

 M. Hein, J. Eisert, H.J. Briegel, Multi-party Entanglement in Graph States,

arXiv:0307130

 D. Koh, Further Extensions of Clifford Circuits & their Classical Simulation Complexities.

arXiv:1512.07892

Create graph state preparation circuit.

Parameters

adjacency_matrix (Union[List, array]) – input graph as n-by-n list of 0-1 lists

Raises

CircuitError – If adjacency_matrix is not symmetric.

The circuit prepares a graph state with the given adjacency matrix.

Attributes

 GraphState.ancillas Returns a list of ancilla bits in the order that the registers were added. GraphState.calibrations Return calibration dictionary. GraphState.clbits Returns a list of classical bits in the order that the registers were added. GraphState.data Return the circuit data (instructions and context). GraphState.extension_lib GraphState.global_phase Return the global phase of the circuit in radians. GraphState.header GraphState.instances GraphState.num_ancillas Return the number of ancilla qubits. GraphState.num_clbits Return number of classical bits. GraphState.num_parameters Convenience function to get the number of parameter objects in the circuit. GraphState.num_qubits Return number of qubits. GraphState.parameters Convenience function to get the parameters defined in the parameter table. GraphState.prefix GraphState.qubits Returns a list of quantum bits in the order that the registers were added.

Methods

 Return indexed operation. Return number of operations in circuit. GraphState.add_calibration(gate, qubits, …) Register a low-level, custom pulse definition for the given gate. Add registers. GraphState.append(instruction[, qargs, cargs]) Append one or more instructions to the end of the circuit, modifying the circuit in place. GraphState.assign_parameters(param_dict[, …]) Assign parameters to new parameters or values. GraphState.barrier(*qargs) Apply Barrier. GraphState.bind_parameters(value_dict) Assign numeric parameters to values yielding a new circuit. GraphState.cast(value, _type) Best effort to cast value to type. Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits. GraphState.ccx(control_qubit1, …) Apply CCXGate. GraphState.ch(control_qubit, target_qubit[, …]) Apply CHGate. Return the current number of instances of this class, useful for auto naming. Return the prefix to use for auto naming. GraphState.cnot(control_qubit, target_qubit) Apply CXGate. Append rhs to self if self contains compatible registers. GraphState.compose(other[, qubits, clbits, …]) Compose circuit with other circuit or instruction, optionally permuting wires. GraphState.control([num_ctrl_qubits, label, …]) Control this circuit on num_ctrl_qubits qubits. GraphState.copy([name]) Copy the circuit. Count each operation kind in the circuit. GraphState.cp(theta, control_qubit, target_qubit) Apply CPhaseGate. GraphState.crx(theta, control_qubit, …[, …]) Apply CRXGate. GraphState.cry(theta, control_qubit, …[, …]) Apply CRYGate. GraphState.crz(theta, control_qubit, …[, …]) Apply CRZGate. GraphState.cswap(control_qubit, …[, …]) Apply CSwapGate. GraphState.csx(control_qubit, target_qubit) Apply CSXGate. GraphState.cu(theta, phi, lam, gamma, …[, …]) Apply CUGate. GraphState.cu1(theta, control_qubit, …[, …]) Apply CU1Gate. GraphState.cu3(theta, phi, lam, …[, …]) Apply CU3Gate. GraphState.cx(control_qubit, target_qubit[, …]) Apply CXGate. GraphState.cy(control_qubit, target_qubit[, …]) Apply CYGate. GraphState.cz(control_qubit, target_qubit[, …]) Apply CZGate. GraphState.dcx(qubit1, qubit2) Apply DCXGate. Call a decomposition pass on this circuit, to decompose one level (shallow decompose). GraphState.delay(duration[, qarg, unit]) Apply Delay. Return circuit depth (i.e., length of critical path). GraphState.diag_gate(diag, qubit) Deprecated version of QuantumCircuit.diagonal. GraphState.diagonal(diag, qubit) Attach a diagonal gate to a circuit. GraphState.draw([output, scale, filename, …]) Draw the quantum circuit. Append QuantumCircuit to the right hand side if it contains compatible registers. GraphState.fredkin(control_qubit, …) Apply CSwapGate. Take in a QASM file and generate a QuantumCircuit object. GraphState.from_qasm_str(qasm_str) Take in a QASM string and generate a QuantumCircuit object. GraphState.h(qubit) Apply HGate. GraphState.hamiltonian(operator, time, qubits) Apply hamiltonian evolution to to qubits. GraphState.has_register(register) Test if this circuit has the register r. GraphState.i(qubit) Apply IGate. GraphState.id(qubit) Apply IGate. GraphState.initialize(params, qubits) Apply initialize to circuit. Invert (take adjoint of) this circuit. GraphState.iso(isometry, q_input, …[, …]) Attach an arbitrary isometry from m to n qubits to a circuit. GraphState.isometry(isometry, q_input, …) Attach an arbitrary isometry from m to n qubits to a circuit. GraphState.iswap(qubit1, qubit2) Apply iSwapGate. GraphState.mcmt(gate, control_qubits, …[, …]) Apply a multi-control, multi-target using a generic gate. GraphState.mcp(lam, control_qubits, target_qubit) Apply MCPhaseGate. GraphState.mcrx(theta, q_controls, q_target) Apply Multiple-Controlled X rotation gate GraphState.mcry(theta, q_controls, q_target, …) Apply Multiple-Controlled Y rotation gate GraphState.mcrz(lam, q_controls, q_target[, …]) Apply Multiple-Controlled Z rotation gate GraphState.mct(control_qubits, target_qubit) Apply MCXGate. GraphState.mcu1(lam, control_qubits, …) Apply MCU1Gate. GraphState.mcx(control_qubits, target_qubit) Apply MCXGate. GraphState.measure(qubit, cbit) Measure quantum bit into classical bit (tuples). GraphState.measure_active([inplace]) Adds measurement to all non-idle qubits. GraphState.measure_all([inplace]) Adds measurement to all qubits. DEPRECATED: use circuit.reverse_ops(). GraphState.ms(theta, qubits) Apply MSGate. How many non-entangled subcircuits can the circuit be factored to. Return number of non-local gates (i.e. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. Computes the number of tensor factors in the unitary (quantum) part of the circuit only. GraphState.p(theta, qubit) Apply PhaseGate. GraphState.power(power[, matrix_power]) Raise this circuit to the power of power. GraphState.qasm([formatted, filename]) Return OpenQASM string. Converts several qubit representations (such as indexes, range, etc.) into a list of qubits. GraphState.qubit_duration(*qubits) Return the duration between the start and stop time of the first and last instructions, excluding delays, over the supplied qubits. Return the start time of the first instruction, excluding delays, over the supplied qubits. GraphState.qubit_stop_time(*qubits) Return the stop time of the last instruction, excluding delays, over the supplied qubits. GraphState.r(theta, phi, qubit) Apply RGate. GraphState.rcccx(control_qubit1, …) Apply RC3XGate. GraphState.rccx(control_qubit1, …) Apply RCCXGate. Removes final measurement on all qubits if they are present. Repeat this circuit reps times. GraphState.reset(qubit) Reset q. Return a circuit with the opposite order of wires. Reverse the circuit by reversing the order of instructions. GraphState.rx(theta, qubit[, label]) Apply RXGate. GraphState.rxx(theta, qubit1, qubit2) Apply RXXGate. GraphState.ry(theta, qubit[, label]) Apply RYGate. GraphState.ryy(theta, qubit1, qubit2) Apply RYYGate. GraphState.rz(phi, qubit) Apply RZGate. GraphState.rzx(theta, qubit1, qubit2) Apply RZXGate. GraphState.rzz(theta, qubit1, qubit2) Apply RZZGate. GraphState.s(qubit) Apply SGate. GraphState.sdg(qubit) Apply SdgGate. Returns total number of gate operations in circuit. GraphState.snapshot(label[, snapshot_type, …]) Take a statevector snapshot of the internal simulator representation. GraphState.snapshot_density_matrix(label[, …]) Take a density matrix snapshot of simulator state. Take a snapshot of expectation value of an Operator. GraphState.snapshot_probabilities(label, qubits) Take a probability snapshot of the simulator state. Take a stabilizer snapshot of the simulator state. Take a statevector snapshot of the simulator state. GraphState.squ(unitary_matrix, qubit[, …]) Decompose an arbitrary 2*2 unitary into three rotation gates. GraphState.swap(qubit1, qubit2) Apply SwapGate. GraphState.sx(qubit) Apply SXGate. GraphState.sxdg(qubit) Apply SXdgGate. GraphState.t(qubit) Apply TGate. GraphState.tdg(qubit) Apply TdgGate. GraphState.to_gate([parameter_map, label]) Create a Gate out of this circuit. GraphState.to_instruction([parameter_map]) Create an Instruction out of this circuit. GraphState.toffoli(control_qubit1, …) Apply CCXGate. GraphState.u(theta, phi, lam, qubit) Apply UGate. GraphState.u1(theta, qubit) Apply U1Gate. GraphState.u2(phi, lam, qubit) Apply U2Gate. GraphState.u3(theta, phi, lam, qubit) Apply U3Gate. GraphState.uc(gate_list, q_controls, q_target) Attach a uniformly controlled gates (also called multiplexed gates) to a circuit. GraphState.ucrx(angle_list, q_controls, q_target) Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit. GraphState.ucry(angle_list, q_controls, q_target) Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit. GraphState.ucrz(angle_list, q_controls, q_target) Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit. GraphState.unitary(obj, qubits[, label]) Apply unitary gate to q. Return number of qubits plus clbits in circuit. GraphState.x(qubit[, label]) Apply XGate. GraphState.y(qubit) Apply YGate. GraphState.z(qubit) Apply ZGate. Return indexed operation. Return number of operations in circuit.