Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

client2.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import abp
  2. import atexit
  3. import json
  4. from websocket import create_connection
  5. class ServedState(abp.GraphState):
  6. def __init__(self):
  7. abp.GraphState.__init__(self)
  8. self.ws = create_connection("ws://localhost:5001")
  9. atexit.register(self.ws.close)
  10. self.send("clear")
  11. def send(self, method, *args, **kwargs):
  12. kwargs.update({"method":method})
  13. self.ws.send(json.dumps(kwargs))
  14. def add_node(self, node):
  15. abp.GraphState.add_node(self, node)
  16. self.send("add_node", node = node)
  17. def add_edge(self, start, end):
  18. abp.GraphState.add_edge(self, start, end)
  19. self.send("add_edge", start = start, end = end)
  20. def del_edge(self, start, end):
  21. abp.GraphState.del_edge(self, start, end)
  22. self.send("del_edge", start = start, end = end)
  23. def del_edge(self, start, end):
  24. abp.GraphState.del_edge(self, start, end)
  25. self.send("del_edge", start = start, end = end)
  26. if __name__ == '__main__':
  27. s = ServedState()
  28. s.add_node(0)
  29. s.add_node(1)
  30. s.add_edge(0,1)