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.

52 lines
1.3KB

  1. from graph import *
  2. def test_graph():
  3. g, v = graph()
  4. add_edge(g, 0,1)
  5. add_edge(g, 1,2)
  6. add_edge(g, 2,0)
  7. assert g[0]==set([1,2])
  8. del_edge(g, 0,1)
  9. assert g[0]==set([2])
  10. el = edgelist(g)
  11. assert (1,2) in el
  12. assert not (0,1) in el
  13. assert len(el)==2
  14. assert has_edge(g, 1,2)
  15. assert not has_edge(g, 0,1)
  16. def test_local_complementation():
  17. """ Test that local complementation works as expected """
  18. g, vops = graph()
  19. add_edge(g, 0, 1)
  20. add_edge(g, 0, 2)
  21. add_edge(g, 1, 2)
  22. add_edge(g, 0, 3)
  23. local_complementation(g, vops, 0)
  24. assert has_edge(g, 0, 1)
  25. assert has_edge(g, 0, 2)
  26. assert not has_edge(g, 1, 2)
  27. assert has_edge(g, 3, 2)
  28. assert has_edge(g, 3, 1)
  29. # TODO: test VOP conditions
  30. def test_remove_vop():
  31. """ Test that removing VOPs really works """
  32. g, vops = graph()
  33. add_edge(g, 0, 1)
  34. add_edge(g, 0, 2)
  35. add_edge(g, 1, 2)
  36. add_edge(g, 0, 3)
  37. remove_vop(g, vops, 0, 1)
  38. assert vops[0] == clifford.by_name["identity"]
  39. remove_vop(g, vops, 1, 1)
  40. assert vops[1] == clifford.by_name["identity"]
  41. remove_vop(g, vops, 2, 1)
  42. assert vops[2] == clifford.by_name["identity"]
  43. remove_vop(g, vops, 0, 1)
  44. assert vops[0] == clifford.by_name["identity"]