Class: Newral::Classifier::NodeDistance

Inherits:
Object
  • Object
show all
Defined in:
lib/newral/classifier/node_distance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node1, node2) ⇒ NodeDistance

Returns a new instance of NodeDistance.



6
7
8
9
10
# File 'lib/newral/classifier/node_distance.rb', line 6

def initialize( node1, node2 )
  @node1 = node1 
  @node2 = node2 
  @distance = Newral::Tools.euclidian_distance( node1.center, node2.center )
end

Instance Attribute Details

#distanceObject (readonly)

Returns the value of attribute distance.



5
6
7
# File 'lib/newral/classifier/node_distance.rb', line 5

def distance
  @distance
end

#node1Object (readonly)

Returns the value of attribute node1.



5
6
7
# File 'lib/newral/classifier/node_distance.rb', line 5

def node1
  @node1
end

#node2Object (readonly)

Returns the value of attribute node2.



5
6
7
# File 'lib/newral/classifier/node_distance.rb', line 5

def node2
  @node2
end

Instance Method Details

#<=>(other) ⇒ Object



12
13
14
# File 'lib/newral/classifier/node_distance.rb', line 12

def <=>( other )
  self.distance <=> other.distance
end