Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
952B

  1. from abp.fancy import GraphState as FGS
  2. import abp
  3. from abp.util import xyz
  4. def linear_cluster(n):
  5. g = FGS(range(n), deterministic=True)
  6. g.act_circuit([(i, "hadamard") for i in range(n)])
  7. g.act_circuit([((i, i+1), "cz") for i in range(n-1)])
  8. return g
  9. def test_mercedes_example_1():
  10. """ Run an example provided by mercedes """
  11. g = linear_cluster(5)
  12. g.measure(3, "px", 1)
  13. g.measure(2, "px", 0)
  14. g.remove_nodes_from((2, 3))
  15. print g.node
  16. g = linear_cluster(5)
  17. g.measure(2, "px", 0)
  18. g.measure(3, "px", 0)
  19. g.remove_vop(0, 1)
  20. g.remove_vop(1, 0)
  21. g.remove_nodes_from((2, 3))
  22. a = g.to_state_vector()
  23. print g.node
  24. g = linear_cluster(5)
  25. g.measure(2, "px", 0)
  26. g.measure(3, "px", 1)
  27. g.remove_vop(0, 1)
  28. g.remove_vop(1, 0)
  29. g.remove_nodes_from((2, 3))
  30. b = g.to_state_vector()
  31. print g.node
  32. if __name__ == '__main__':
  33. test_mercedes_example_1()