private double distance ( Instance inst1 , Instance inst2 ) { double dist = 0.0 ; for ( int i = 0 ; i < inst1 . numAttributes ( ) ; i ++ ) { dist += Math . pow ( ( inst1 . value ( i ) - inst2 . value ( i ) ) , 2.0 ) ; } return Math . sqrt ( dist ) ; }
Calculates the Euclidean distance between two instances .