public int purge ( int minPts ) { List < Neuron > outliers = new ArrayList <> ( ) ; for ( Neuron neuron : neurons ) { if ( neuron . n < minPts ) { outliers . add ( neuron ) ; } } neurons . removeAll ( outliers ) ; for ( Neuron neuron : neurons ) { neuron . neighbors . removeAll ( outliers ) ; } outliers . clear ( ) ; for ( Neuron neuron : neurons ) { if ( neuron . neighbors . isEmpty ( ) ) { outliers . add ( neuron ) ; } } neurons . removeAll ( outliers ) ; return neurons . size ( ) ; }
Removes neurons with the number of samples less than a given threshold . The neurons without neighbors will also be removed .