Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node
- @@nodes = []
- attr_accessor :x, :y
- attr_accessor :id, :label
- def initialize(id, x, y)
- @id = id
- @x = x
- @y = y
- @@nodes.push self
- end
- def self.find_nodes(x, y, r)
- @@nodes.clone.reject { |n| (x-n.x)**2 + (y-n.y)**2 > r**2 } # Do i really need the clone() here?
- end
- def get_neighbors(r)
- self.class.find_nodes(@x, @y, r) - [self]
- end
- end
Add Comment
Please, Sign In to add comment