Demo entry 6678335

buffer

   

Submitted by anonymous on Dec 06, 2017 at 03:56
Language: Java. Code size: 2.1 kB.

	private boolean bufferClusters(DataObject dataObject){
    	if (dataObject.getClusterLabel() != DataObject.UNCLASSIFIED && dataObject.getClusterLabel() != DataObject.NOISE){
    		return false;
    	}
    	List seedList = database.epsilonRangeQuery(getEpsilon(), dataObject);
    	List bufferList = database.epsilonRangeQuery(getEpsilon() * 1.5, dataObject);
    	if(seedList.size() / bufferList.size() >= 0.5 && seedList.size() > getMinPoints() * 0.6){
    		for (int i = 0; i < seedList.size(); i++) {
                DataObject seedListDataObject = (DataObject) seedList.get(i);
                seedListDataObject.setClusterLabel(clusterID);
                if (seedListDataObject.equals(dataObject)) {
                    seedList.remove(i);
                    i--;
                }
            }

	    	for (int j = 0; j < seedList.size(); j++) {
	            DataObject seedListDataObject = (DataObject) seedList.get(j);
	            List seedListDataObject_Neighbourhood = database.epsilonRangeQuery(getEpsilon(), seedListDataObject);
	            List bufferListDataObject_Neighbourhood = database.epsilonRangeQuery(getEpsilon() * 1.5, seedListDataObject);
	            /** seedListDataObject is coreObject */
	            if (seedListDataObject_Neighbourhood.size() >= getMinPoints() * 0.6 && 
	            		seedListDataObject_Neighbourhood.size() / bufferListDataObject_Neighbourhood.size() >= 0.5) {
	                for (int i = 0; i < seedListDataObject_Neighbourhood.size(); i++) {
	                    DataObject p = (DataObject) seedListDataObject_Neighbourhood.get(i);
	                    if (p.getClusterLabel() == DataObject.UNCLASSIFIED || p.getClusterLabel() == DataObject.NOISE) {
	                        if (p.getClusterLabel() == DataObject.UNCLASSIFIED) {
	                            seedList.add(p);
	                        }
	                        p.setClusterLabel(clusterID);
	                    }
	                }
	            }
	            seedList.remove(j);
	            j--;
	        }
	    	return true;
    	}
    	
    	return false;
    }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).