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.

38 lines
1.0KB

  1. from graph import *
  2. import viz
  3. import itertools as it
  4. import clifford
  5. def local_complementation(g, vops, v):
  6. """ As defined in LISTING 1 of Anders & Briegel """
  7. for i, j in it.combinations(g[v], 2):
  8. toggle_edge(g, i, j)
  9. # Update VOPs
  10. vops[v] = clifford.times_table[vops[v]][clifford.sqx]
  11. for i in g[v]:
  12. vops[i] = clifford.times_table[vops[i]][clifford.msqz]
  13. def remove_vop(g, vops, a, b):
  14. """ Reduces VOP[a] to the identity, avoiding (if possible) the use of vertex b as a swapping partner """
  15. free_neighbours = g[a] - {b}
  16. c = b if len(free_neighbours) == 0 else free_neighbours.pop()
  17. d = clifford.decompositions[a]
  18. for v in reversed(d):
  19. target = a if v == clifford.sqx else b
  20. local_complementation(g, vops, target)
  21. if __name__ == '__main__':
  22. g, vops = graph()
  23. add_edge(g, 0, 1)
  24. add_edge(g, 1, 2)
  25. add_edge(g, 0, 2)
  26. add_edge(g, 0, 3)
  27. viz.draw(g, vops, "out.pdf")
  28. local_complementation(g, vops, 0)
  29. viz.draw(g, vops, "out2.pdf")