module Connected::Edge
Used to mixin a direct connection between two Vertices (an Edge
) on a graph
Public Instance Methods
<=>(other)
click to toggle source
# File lib/connected/edge.rb, line 41 def <=>(other) if (open? && other.open?) || (closed? && other.closed?) metric <=> other.metric elsif open? -1 elsif other.open? 1 end end
closed?()
click to toggle source
# File lib/connected/edge.rb, line 23 def closed? unless respond_to?(:state) # Expect classes to describe how to determine if they're closed raise "#state() or #closed? MUST be implemented on #{self.class.name}" end state.to_s == :closed.to_s end
from()
click to toggle source
# File lib/connected/edge.rb, line 8 def from # Expect classes to describe the "from" Vertex raise "#from() MUST be implemented on #{self.class.name}" end
metric()
click to toggle source
This should almost certainly be overridden
# File lib/connected/edge.rb, line 19 def metric 1 end
open?()
click to toggle source
# File lib/connected/edge.rb, line 32 def open? unless respond_to?(:state) # Expect classes to describe how to determine if they're open raise "#state() or #open? MUST be implemented on #{self.class.name}" end state.to_s == :open.to_s end
to()
click to toggle source
# File lib/connected/edge.rb, line 13 def to # Expect classes to describe the "to" Vertex raise "#to() MUST be implemented on #{self.class.name}" end