Module: Connected::Vertex
- Included in:
- GenericNode
- Defined in:
- lib/connected/vertex.rb
Overview
Vertices are based on a mixin
Instance Method Summary collapse
-
#connection_to(other) ⇒ Object
Retrieves the Connection object responsible for connecting to a Node.
- #connections ⇒ Object
-
#neighbors ⇒ Object
A shortcut for retrieving this node’s neighbors.
Instance Method Details
#connection_to(other) ⇒ Object
Retrieves the Connection object responsible for connecting to a Node
17 18 19 |
# File 'lib/connected/vertex.rb', line 17 def connection_to(other) connections.select { |c| c.to == other }.min_by(&:metric) end |
#connections ⇒ Object
6 7 8 9 |
# File 'lib/connected/vertex.rb', line 6 def connections # Expect classes to describe how to find connections raise "#connections() MUST be implemented on #{self.class.name}" end |
#neighbors ⇒ Object
A shortcut for retrieving this node’s neighbors
12 13 14 |
# File 'lib/connected/vertex.rb', line 12 def neighbors connections.map(&:to).uniq end |