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.

53 lines
1.2KB

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