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.

33 lines
712B

  1. from abp import GraphState
  2. from anders_briegel import graphsim
  3. from abp import clifford
  4. import random, difflib, re
  5. from copy import deepcopy
  6. def isequal(a, b):
  7. """ TODO: Sketchy as you like. Remove this abomination """
  8. aa = a.get_adj_list()
  9. bb = b.adj_list()
  10. return re.sub("\\s", "", aa) == re.sub("\\s", "", bb)
  11. clifford.use_old_cz()
  12. N = 3
  13. a = graphsim.GraphRegister(N)
  14. b = GraphState(range(N))
  15. previous_state, previous_cz = None, None
  16. while isequal(a, b):
  17. if random.random()>0.5:
  18. j = random.randint(0, N-1)
  19. a.hadamard(j)
  20. b.act_hadamard(j)
  21. else:
  22. q = random.randint(0, N-2)
  23. if a!=b:
  24. a.cphase(q, q+1)
  25. b.act_cz(q, q+1)