Open Graph¶
graphix.opengraph module¶
This module defines classes for defining MBQC patterns as Open Graphs.
- class graphix.opengraph.OpenGraph(graph: nx.Graph[int], input_nodes: Sequence[int], output_nodes: Sequence[int], measurements: Mapping[int, _M_co])[source]¶
An unmutable dataclass providing a representation of open graph states.
- graph¶
The underlying resource-state graph. Nodes represent qubits and edges represent the application of \(CZ\) gate on the linked nodes.
- Type:
networkx.Graph[int]
- input_nodes¶
An ordered sequence of node labels corresponding to the open graph inputs.
- Type:
Sequence[int]
- output_nodes¶
An ordered sequence of node labels corresponding to the open graph outputs.
- Type:
Sequence[int]
- measurements¶
A mapping between the non-output nodes of the open graph (
key) and their corresponding measurement label (value). Measurement labels can be specified asMeasurement,PlaneorAxisinstances.- Type:
Mapping[int, _M_co]
Notes
The inputs and outputs of
OpenGraphinstances in Graphix are defined as ordered sequences of node labels. This contrasts the usual definition of open graphs in the literature, where inputs and outputs are unordered sets of nodes labels. This restriction facilitates the interplay withPatternobjects, where the order of input and output nodes represents a choice of Hilbert space basis.Example
>>> import networkx as nx >>> from graphix.fundamentals import Plane >>> from graphix.opengraph import OpenGraph >>> from graphix.measurements import Measurement >>> >>> graph = nx.Graph([(0, 1), (1, 2)]) >>> measurements = {i: Measurement(0.5 * i, Plane.XY) for i in range(2)} >>> input_nodes = [0] >>> output_nodes = [2] >>> og = OpenGraph(graph, input_nodes, output_nodes, measurements)