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 [2].

Reference Circuit:

../_images/qiskit.circuit.library.GraphState_0_0.png

References:

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

arXiv:0307130

[2] 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

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

Attributes

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.header

GraphState.instances

GraphState.n_qubits

Deprecated, use num_qubits instead.

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

GraphState.AND(qr_variables, qb_target, …)

Build a collective conjunction (AND) circuit in place using mct.

GraphState.OR(qr_variables, qb_target, …)

Build a collective disjunction (OR) circuit in place using mct.

GraphState.__getitem__(item)

Return indexed operation.

GraphState.__len__()

Return number of operations in circuit.

GraphState.add_register(*regs)

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.

GraphState.cbit_argument_conversion(…)

Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits.

GraphState.ccx(control_qubit1, …[, ctl1, …])

Apply CCXGate.

GraphState.ch(control_qubit, target_qubit, *)

Apply CHGate.

GraphState.cls_instances()

Return the current number of instances of this class, useful for auto naming.

GraphState.cls_prefix()

Return the prefix to use for auto naming.

GraphState.cnot(control_qubit, target_qubit, *)

Apply CXGate.

GraphState.combine(rhs)

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.copy([name])

Copy the circuit.

GraphState.count_ops()

Count each operation kind in the circuit.

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.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.

GraphState.decompose()

Call a decomposition pass on this circuit, to decompose one level (shallow decompose).

GraphState.depth()

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.

GraphState.extend(rhs)

Append QuantumCircuit to the right hand side if it contains compatible registers.

GraphState.fredkin(control_qubit, …[, …])

Apply CSwapGate.

GraphState.from_qasm_file(path)

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, *[, q])

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, *[, q])

Apply IGate.

GraphState.id(qubit, *[, q])

Apply IGate.

GraphState.iden(qubit, *[, q])

Deprecated identity gate.

GraphState.initialize(params, qubits)

Apply initialize to circuit.

GraphState.inverse()

Invert 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.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.

GraphState.mirror()

Mirror the circuit by reversing the instructions.

GraphState.ms(theta, qubits)

Apply MSGate.

GraphState.num_connected_components([…])

How many non-entangled subcircuits can the circuit be factored to.

GraphState.num_nonlocal_gates()

Return number of non-local gates (i.e.

GraphState.num_tensor_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

GraphState.num_unitary_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

GraphState.qasm([formatted, filename])

Return OpenQASM string.

GraphState.qbit_argument_conversion(…)

Converts several qubit representations (such as indexes, range, etc.) into a list of qubits.

GraphState.r(theta, phi, qubit, *[, q])

Apply RGate.

GraphState.rcccx(control_qubit1, …)

Apply RC3XGate.

GraphState.rccx(control_qubit1, …)

Apply RCCXGate.

GraphState.remove_final_measurements([inplace])

Removes final measurement on all qubits if they are present.

GraphState.reset(qubit)

Reset q.

GraphState.rx(theta, qubit, *[, label, q])

Apply RXGate.

GraphState.rxx(theta, qubit1, qubit2)

Apply RXXGate.

GraphState.ry(theta, qubit, *[, label, q])

Apply RYGate.

GraphState.ryy(theta, qubit1, qubit2)

Apply RYYGate.

GraphState.rz(phi, qubit, *[, q])

Apply RZGate.

GraphState.rzx(theta, qubit1, qubit2)

Apply RZXGate.

GraphState.rzz(theta, qubit1, qubit2)

Apply RZZGate.

GraphState.s(qubit, *[, q])

Apply SGate.

GraphState.sdg(qubit, *[, q])

Apply SdgGate.

GraphState.size()

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.

GraphState.snapshot_expectation_value(label, …)

Take a snapshot of expectation value <O> of an Operator.

GraphState.snapshot_probabilities(label, qubits)

Take a probability snapshot of the simulator state.

GraphState.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

GraphState.snapshot_statevector(label)

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.t(qubit, *[, q])

Apply TGate.

GraphState.tdg(qubit, *[, q])

Apply TdgGate.

GraphState.to_gate([parameter_map])

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.u1(theta, qubit, *[, q])

Apply U1Gate.

GraphState.u2(phi, lam, qubit, *[, q])

Apply U2Gate.

GraphState.u3(theta, phi, lam, qubit, *[, q])

Apply U3Gate.

GraphState.uc(gate_list, q_controls, q_target)

Attach a uniformly controlled gates (also called multiplexed gates) to a circuit.

GraphState.ucg(angle_list, q_controls, q_target)

Deprecated version of uc.

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.ucx(angle_list, q_controls, q_target)

Deprecated version of ucrx.

GraphState.ucy(angle_list, q_controls, q_target)

Deprecated version of ucry.

GraphState.ucz(angle_list, q_controls, q_target)

Deprecated version of ucrz.

GraphState.unitary(obj, qubits[, label])

Apply unitary gate to q.

GraphState.width()

Return number of qubits plus clbits in circuit.

GraphState.x(qubit, *[, label, ctrl_state, q])

Apply XGate.

GraphState.y(qubit, *[, q])

Apply YGate.

GraphState.z(qubit, *[, q])

Apply ZGate.

GraphState.__len__()

Return number of operations in circuit.

GraphState.__getitem__(item)

Return indexed operation.