private void initialClustering ( ) { //System.out.println("INITIAL CLUSTERING CALLED"); //printDStreamState(); // 1. Update the density of all grids in grid_list updateGridListDensity ( ) ; //printGridList(); // 2. Assign each dense grid to a distinct cluster // and // 3. Label all other grids as NO_CLASS Iterator < Map . Entry < DensityGrid , CharacteristicVector > > glIter = this . grid_list . entrySet ( ) . iterator ( ) ; HashMap < DensityGrid , CharacteristicVector > newGL = new HashMap < DensityGrid , CharacteristicVector > ( ) ; while ( glIter . hasNext ( ) ) { Map . Entry < DensityGrid , CharacteristicVector > grid = glIter . next ( ) ; DensityGrid dg = grid . getKey ( ) ; CharacteristicVector cvOfG = grid . getValue ( ) ; //System.out.print(dg.toString()); if ( cvOfG . getAttribute ( ) == DENSE ) { int gridClass = this . cluster_list . size ( ) ; cvOfG . setLabel ( gridClass ) ; GridCluster gc = new GridCluster ( ( CFCluster ) dg , new ArrayList < CFCluster > ( ) , gridClass ) ; gc . addGrid ( dg ) ; this . cluster_list . add ( gc ) ; //System.out.print(" was dense (class "+gridClass+")"); } else cvOfG . setLabel ( NO_CLASS ) ; //System.out.println(); newGL . put ( dg , cvOfG ) ; } this . grid_list = newGL ; //printGridClusters(); // 4. Make changes to grid labels by doing: // a. For each cluster c // b. For each outside grid g of c // c. For each neighbouring grid h of g // d. If h belongs to c', label c and c' with // the label of the largest cluster // e. Else if h is transitional, assign it to c // f. While changes can be made boolean changesMade ; do { changesMade = adjustLabels ( ) ; } while ( changesMade ) ; // while changes are being made //printGridList(); //printGridClusters(); }
Implements the procedure given in Figure 3 of Chen and Tu 2007