Guest User

Untitled

a guest
Oct 17th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. def addNode(self, node_id, x, y):
  2. if self.node_list[node_id] != None:
  3. raise exception("This node ID already exists.")
  4. else:
  5. if self.spacialMatrix[x][y] != None:
  6. raise exception("This node position is already populated.")
  7. else:
  8. self.spacialMatrix[x][y] = node_id
  9. self.node_list[node_id] = [x,y]
  10.  
  11. def addNode(self, node_id, x, y):
  12. if self.node_list[node_id] != None:
  13.  
  14. raise exception("This node ID already exists.")
  15.  
  16. else:
  17.  
  18. if self.spacialMatrix[x][y] != None:
  19. raise exception("This node position is already populated.")
  20.  
  21. else:
  22. self.spacialMatrix[x][y] = node_id
  23. self.node_list[node_id] = [x,y]
  24.  
  25. class NodeError(exception):
  26. """
  27. For node related errors.
  28. """
  29. pass
  30.  
  31. def addNode(self, node_id, x, y):
  32. if self.node_list[node_id] is not None:
  33. raise NodeError("This node ID already exists.")
  34. if self.spacialMatrix[x][y] is not None:
  35. raise NodeError("This node position is already populated.")
  36. self.spacialMatrix[x][y] = node_id
  37. self.node_list[node_id] = [x,y]
  38.  
  39. def addNode(self, node_id, x, y):
  40. assert self.node_list[node_id] is None
  41. assert self.spacialMatrix[x][y] is None
  42.  
  43. self.spacialMatrix[x][y] = node_id
  44. self.node_list[node_id] = [x, y]
Add Comment
Please, Sign In to add comment