|
|
@@ -1,18 +1,20 @@ |
|
|
|
from abp.fancy import GraphState |
|
|
|
import networkx as nx |
|
|
|
from abp import GraphState, VizClient |
|
|
|
from abp.util import xyz |
|
|
|
|
|
|
|
edges = [(0,1),(1,2),(2,3),(3,4)] |
|
|
|
nodes = [(i, {'x': i, 'y': 0, 'z':0}) for i in range(5)] |
|
|
|
gs = GraphState() |
|
|
|
# Prepare to visualize |
|
|
|
v = VizClient() |
|
|
|
|
|
|
|
for node, position in nodes: |
|
|
|
gs.add_qubit(node, position=position) |
|
|
|
gs.act_hadamard(node) |
|
|
|
# Make a graph state with position attributes |
|
|
|
g = GraphState() |
|
|
|
for i in range(5): |
|
|
|
g.add_qubit(i, position=xyz(i, 0, 0), vop="identity") |
|
|
|
g.act_czs((0,1),(1,2),(2,3),(3,4)) |
|
|
|
|
|
|
|
for edge in edges: |
|
|
|
gs.act_cz(*edge) |
|
|
|
gs.update(3) |
|
|
|
# a single line of qubits are created along the x axis |
|
|
|
gs.add_qubit('start') |
|
|
|
gs.update(0) |
|
|
|
# a curved 5-qubit cluster and single qubit is depicted |
|
|
|
# Show it |
|
|
|
v.update(g, 3) |
|
|
|
|
|
|
|
# Add a qubit with no position |
|
|
|
g.add_qubit('start') |
|
|
|
|
|
|
|
# Show it |
|
|
|
v.update(g) |