public Clustering < SubspaceModel > run ( Relation < ? extends NumberVector > relation ) { final int dimensionality = RelationUtil . dimensionality ( relation ) ; StepProgress step = new StepProgress ( 2 ) ; // 1. Identification of subspaces that contain clusters step . beginStep ( 1 , "Identification of subspaces that contain clusters" , LOG ) ; ArrayList < List < CLIQUESubspace > > dimensionToDenseSubspaces = new ArrayList <> ( dimensionality ) ; List < CLIQUESubspace > denseSubspaces = findOneDimensionalDenseSubspaces ( relation ) ; dimensionToDenseSubspaces . add ( denseSubspaces ) ; if ( LOG . isVerbose ( ) ) { LOG . verbose ( "1-dimensional dense subspaces: " + denseSubspaces . size ( ) ) ; } if ( LOG . isDebugging ( ) ) { for ( CLIQUESubspace s : denseSubspaces ) { LOG . debug ( s . toString ( ) ) ; } } for ( int k = 2 ; k <= dimensionality && ! denseSubspaces . isEmpty ( ) ; k ++ ) { denseSubspaces = findDenseSubspaces ( relation , denseSubspaces ) ; assert ( dimensionToDenseSubspaces . size ( ) == k - 1 ) ; dimensionToDenseSubspaces . add ( denseSubspaces ) ; if ( LOG . isVerbose ( ) ) { LOG . verbose ( k + "-dimensional dense subspaces: " + denseSubspaces . size ( ) ) ; } if ( LOG . isDebugging ( ) ) { for ( CLIQUESubspace s : denseSubspaces ) { LOG . debug ( s . toString ( ) ) ; } } } // 2. Identification of clusters step . beginStep ( 2 , "Identification of clusters" , LOG ) ; // build result Clustering < SubspaceModel > result = new Clustering <> ( "CLIQUE clustering" , "clique-clustering" ) ; for ( int dim = 0 ; dim < dimensionToDenseSubspaces . size ( ) ; dim ++ ) { List < CLIQUESubspace > subspaces = dimensionToDenseSubspaces . get ( dim ) ; List < Pair < Subspace , ModifiableDBIDs > > modelsAndClusters = determineClusters ( subspaces ) ; if ( LOG . isVerbose ( ) ) { LOG . verbose ( ( dim + 1 ) + "-dimensional clusters: " + modelsAndClusters . size ( ) ) ; } for ( Pair < Subspace , ModifiableDBIDs > modelAndCluster : modelsAndClusters ) { Cluster < SubspaceModel > newCluster = new Cluster <> ( modelAndCluster . second ) ; newCluster . setModel ( new SubspaceModel ( modelAndCluster . first , Centroid . make ( relation , modelAndCluster . second ) . getArrayRef ( ) ) ) ; result . addToplevelCluster ( newCluster ) ; } } return result ; }
Performs the CLIQUE algorithm on the given database .