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.

8 jaren geleden
1234567891011121314151617181920212223242526272829
  1. from graph import Graph
  2. from matplotlib import pyplot as plt
  3. class GraphState(Graph):
  4. def __init__(self, n):
  5. Graph.__init__(self, n)
  6. def local_complementation(self, a):
  7. for i in self.neighbours[a]:
  8. for j in self.neighbours[a]:
  9. if i<j:
  10. self.toggle_edge(i, j)
  11. if __name__ == '__main__':
  12. g = GraphState(10)
  13. g.add_edge(0, 1)
  14. g.add_edge(1, 3)
  15. g.add_edge(3, 2)
  16. g.add_edge(3, 0)
  17. g.add_edge(2, 0)
  18. g.add_edge(0, 5)
  19. g.vops[0]=1
  20. g.draw()
  21. plt.clf()
  22. g.local_complementation(0)
  23. g.draw("out2.pdf")