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.

54 lines
1.2KB

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