00001 /*========================================================================== 00002 * Copyright (c) 2002 University of Massachusetts. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.lemurproject.org/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 // David Fisher 00013 // init: 11/20/2002 00014 // Centroid clustering algorithms. 00015 #ifndef _CENTROIDCLUSTER_HPP 00016 #define _CENTROIDCLUSTER_HPP 00017 #include "Cluster.hpp" 00018 00020 class CentroidCluster: public Cluster 00021 { 00022 public: 00024 CentroidCluster(int cid, const Index &ind, const SimilarityMethod &sim); 00026 virtual ~CentroidCluster() { 00027 delete(centroid); 00028 delete(weightedCentroid); 00029 }; 00031 virtual double score(const ClusterRep *rep) const; 00033 virtual void add(const ClusterElt &elt); 00035 virtual void add(const vector<DOCID_T> docids); 00037 virtual void remove(const ClusterElt &elt); 00039 virtual bool read(ifstream &in); 00040 00044 virtual ClusterRep *getClusterRep() const; 00045 00047 virtual double sum2() const {return weightedCentroid->sum2(); } 00048 00049 private: 00050 FloatFreqVector *centroid; 00051 ClusterRep *weightedCentroid; 00052 FloatFreqVector* readCentroid(); 00053 void updateCentroid(FloatFreqVector *v, bool first); 00054 }; 00055 00056 #endif