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.

31 lines
744B

  1. from matplotlib import pyplot as plt
  2. from graph import *
  3. from viz import draw
  4. import itertools as it
  5. import clifford
  6. def local_complementation(g, vops, v):
  7. """ As defined in LISTING 1 of Anders & Briegel """
  8. for i, j in it.combinations(g[v], 2):
  9. toggle_edge(g, i, j)
  10. # Update VOPs
  11. vops[v] = clifford.times_table[vops[v]][clifford.sqx]
  12. for i in g[v]:
  13. vops[i] = clifford.times_table[vops[i]][clifford.msqz]
  14. if __name__ == '__main__':
  15. g, vops = graph(10)
  16. add_edge(g, 0, 1)
  17. add_edge(g, 1, 3)
  18. add_edge(g, 3, 2)
  19. add_edge(g, 3, 0)
  20. add_edge(g, 2, 0)
  21. add_edge(g, 0, 5)
  22. vops[0] = 1
  23. draw(g, vops)
  24. plt.clf()
  25. local_complementation(g, vops, 0)
  26. draw(g, vops, "out2.pdf")