Graph state simulator
graphix.graphsim module
This provides efficient graph state simulator using the decorated graph method.
- class graphix.graphsim.GraphState(nodes=None, edges=None, vops=None)[source]
Graph state simulator
Performs Pauli measurements on graph states. Inherits methods and attributes from networkx.Graph.
ref: M. Elliot, B. Eastin & C. Caves, JPhysA 43, 025301 (2010) and PRA 77, 042307 (2008)
- Each node has attributes:
- hollow
True if node is hollow
- sign
True if node has negative sign
- loop
True if node has loop
- __init__(nodes=None, edges=None, vops=None)[source]
- Parameters
nodes (iterable container) – A container of nodes (list, dict, etc)
edges (list) – list of tuples (i,j) for pairs to be entangled.
vops (dict) – dict of local Clifford gates with keys for node indices and values for Clifford index (see graphix.clifford.CLIFFORD)
- add_edges_from(edges)[source]
Add edges and initialize node properties of newly added nodes.
- Parameters
edges (iterable container) – must be given as list of 2-tuples (u, v)
- add_nodes_from(nodes)[source]
Add nodes and initialize node properties.
- Parameters
nodes (iterable container) – A container of nodes (list, dict, etc)
- advance(node)[source]
Flips the loop (local S) of a node. If the loop already exist, sign is also flipped, reflecting the relation SS=Z. Note that application of S gate is different from advance if there exist an edge from the node.
- Parameters
node (int) – graph node to advance the loop.
- apply_vops(vops)[source]
Apply local Clifford operators to the graph state from a dictionary
- Parameters
vops (dict) – dict containing node indices as keys and local Clifford indices as values (see graphix.clifford.CLIFFORD)
- draw(fill_color='C0', **kwargs)[source]
Draw decorated graph state. Negative nodes are indicated by negative sign of node labels.
- Parameters
fill_color (str, optional) – fill color of nodes
kwargs (keyword arguments, optional) – additional arguments to supply networkx.draw().
- equivalent_fill_node(node)[source]
Fill the chosen node by graph transformation rules E1 and E2, If the selected node is hollow and isolated, it cannot be filled and warning is thrown.
- Parameters
node (int) – node to fill.
- Returns
result – if the selected node is hollow and isolated, result is 1. if filled and isolated, 2. otherwise it is 0.
- Return type
int
- equivalent_graph_E1(node)[source]
Tranform a graph state to a different graph state representing the same stabilizer state. This rule applies only to a node with loop.
- Parameters
node1 (int) – A graph node with a loop to apply rule E1
- equivalent_graph_E2(node1, node2)[source]
Tranform a graph state to a different graph state representing the same stabilizer state. This rule applies only to two connected nodes without loop.
- Parameters
node1 (int) – connected graph nodes to apply rule E2
node2 (int) – connected graph nodes to apply rule E2
- flip_fill(node)[source]
Flips the fill (local H) of a node.
- Parameters
node (int) – graph node to flip the fill
- flip_sign(node)[source]
Flips the sign (local Z) of a node. Note that application of Z gate is different from flip_sign if there exist an edge from the node.
- Parameters
node (int) – graph node to flip the sign
- get_vops()[source]
Returns a dict containing clifford labels for each nodes. labels 0 - 23 specify one of 24 single-qubit Clifford gates. see graphq.clifford for the definition of all unitaries.
- Returns
vops – clifford gate indices as defined in graphq.clifford.
- Return type
dict
See also
graphix.clifford
- local_complement(node)[source]
Perform local complementation of a graph
- Parameters
node (int) – chosen node for the local complementation
- measure_x(node, choice=0)[source]
perform measurement in X basis According to original paper, we realise X measurement by applying H gate to the measured node before Z measurement.
- Parameters
node (int) – qubit index to be measured
choice (int, 0 or 1) – choice of measurement outcome. observe (-1)^choice
- measure_y(node, choice=0)[source]
perform measurement in Y basis According to original paper, we realise Y measurement by applying S,Z and H gate to the measured node before Z measurement.
- Parameters
node (int) – qubit index to be measured
choice (int, 0 or 1) – choice of measurement outcome. observe (-1)^choice
- measure_z(node, choice=0)[source]
perform measurement in Z basis To realize the simple Z measurement on undecorated graph state, we first fill the measured node (remove local H gate)
- Parameters
node (int) – qubit index to be measured
choice (int, 0 or 1) – choice of measurement outcome. observe (-1)^choice