class mentpy.MBQCircuit

The MBQCircuit class that deals with operations and manipulations of graph states

Parameters:
graph : mp.GraphState

The graph state of the MBQC circuit.

input_nodes : list

The input nodes of the MBQC circuit.

output_nodes : list

The output nodes of the MBQC circuit.

measurements : dict

The measurements of the MBQC circuit. The keys are the nodes and the values are the measurements.

default_measurement : mp.Ment

The default measurement of the MBQC circuit if no measurements are given.

Examples

Create a 1D cluster state \(|G>\) of five qubits

In [1]: g = mp.GraphState()

In [2]: g.add_edges_from([(0,1), (1,2), (2,3), (3, 4)])

In [3]: state = mp.MBQCircuit(g, input_nodes=[0], output_nodes=[4])

See also

mp.GraphState

Constructors

MBQCircuit(graph: GraphState, input_nodes: List[int] = [], ...)

Initializes a graph state

String representation

__repr__() str

Return the representation of the current MBQC circuit state

Special methods

__delitem__(key)

Delete the measurement of the node with index key.

__getitem__(key)

Return the value of the measurement of the node with index key.

__len__() int

Return the number of nodes in the MBQCircuit

__setitem__(key, value)

Set the value of the measurement of the node with index key.

Methods

add_edge(u, v)

Adds an edge between nodes u and v

add_edges_from(edges, **kwargs)

Adds edges from a list of tuples

calculate_order()

Returns the order of the measurements

ordered_layers(train_indices=False) List[List[int]]

Returns the layers of the MBQC circuit.

Properties

property classical_output_nodes : List[int]

Return the output nodes of the MBQC circuit.

property controlled_nodes : List[int]

Return the controlled nodes of the MBQC circuit.

property depth : int

Return the depth of the MBQC circuit.

property flow : Flow

Return the flow function of the MBQC circuit.

property graph : GraphState

Return the graph of the resource state.

property input_nodes : List[int]

Return the input nodes of the MBQC circuit.

property inputc : List

Returns \(I^c\), the complement of input nodes.

property measurement_order : List[int]

Return the measurement order of the MBQC circuit.

property measurements : Dict[int, Ment]

Return the measurements of the MBQC circuit.

property output_nodes : List[int]

Return the output nodes of the MBQC circuit.

property outputc : List

Returns \(O^c\), the complement of output nodes.

property partial_order : Callable

Return the partial order function of the MBQC circuit.

property quantum_output_nodes : List[int]

Return the output nodes of the MBQC circuit.

property trainable_nodes : List[int]

Return the trainable nodes of the MBQC circuit.