Anders and Briegel in Python
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

30 行
609B

  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")