public void testNumberOfNeighbors(){
  int i;
  int instIndex;
  Instances neighbors;
  try {
    m_NearestNeighbourSearch.setInstances(m_Instances);
  }
 catch (  Exception e) {
    fail("Failed setting the instances: " + e);
  }
  for (i=1; i <= m_NumNeighbors; i++) {
    instIndex=m_Random.nextInt(m_Instances.numInstances());
    try {
      neighbors=m_NearestNeighbourSearch.kNearestNeighbours(m_Instances.instance(instIndex),i);
      assertEquals("Returned different number of neighbors than requested",i,neighbors.numInstances());
    }
 catch (    Exception e) {
      fail("Failed for " + i + " neighbors on instance "+ (instIndex + 1)+ ": "+ e);
    }
  }
}

public void testNumberOfNeighbors ( ) { int i ; int instIndex ; Instances neighbors ; try { m_NearestNeighbourSearch . setInstances ( m_Instances ) ; } catch ( Exception e ) { fail ( "Failed setting the instances: " + e ) ; } for ( i = 1 ; i <= m_NumNeighbors ; i ++ ) { instIndex = m_Random . nextInt ( m_Instances . numInstances ( ) ) ; try { neighbors = m_NearestNeighbourSearch . kNearestNeighbours ( m_Instances . instance ( instIndex ) , i ) ; assertEquals ( "Returned different number of neighbors than requested" , i , neighbors . numInstances ( ) ) ; } catch ( Exception e ) { fail ( "Failed for " + i + " neighbors on instance " + ( instIndex + 1 ) + ": " + e ) ; } } }
tests whether the number of instances returned by the algorithms is the same as was requested
