• API Main Page
  • Documentation
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

src/clustering.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Matthias Ihrke                                  *
00003  *   mihrke@uni-goettingen.de                                              *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00025 #ifndef CLUSTERING_H
00026 # define CLUSTERING_H
00027 #include <time.h>
00028 #include "mathadd.h"
00029 #include "definitions.h"
00030 #include "array.h"
00031 #include "averaging.h"
00032 #include "distances.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038   /*-----------------------------------------------------------
00039      - CLUSTERING -
00040      ---------------------------------------------------------*/
00041 
00044   typedef struct{
00045      int **clust; 
00046      int K;       
00047      int *n;      
00048   } Clusters;
00049 
00050 
00056    struct dgram {
00057       int val;       
00058       int clustnum;  
00059       double height; 
00060       struct dgram *left;
00061       struct dgram *right;
00062   };
00063   typedef struct dgram Dendrogram;
00064 
00067   typedef double  (*LinkageFunction)   (const Array*,const Dendrogram*,const Dendrogram*);
00068 
00069 
00070   /* ---------------- CLUSTER ANALYSIS ------------------------------- */
00071   Clusters*    kmedoids(const Array *distmat, int K, OptArgList *optargs );
00072   Clusters*    kmedoids_repeat( const Array *distmat, int K, int repeat );
00073 
00074   Dendrogram*  agglomerative_clustering(const Array *distmat, LinkageFunction dist);
00075 
00076   /* ---------------- CLUSTER HANDLING ------------------------------- */
00077   void      cluster_free(Clusters *c);
00078   void      cluster_print(FILE *out, const Clusters *c);
00079   Clusters* cluster_init(int K, int maxN);
00080   void      cluster_copy(Clusters *dest, const Clusters *src);
00081   int       cluster_compare(const Clusters *c1, const Clusters *c2);
00082 
00083   double   cluster_within_scatter (const Array *distmat, const Clusters *c);
00084   double   cluster_between_scatter(const Array *distmat, const Clusters *c);
00085 
00086   /* ---------------- DENDROGRAM ------------------------------- */
00087   double dgram_dist_singlelinkage  (const Array *d, const Dendrogram *c1, const Dendrogram *c2);
00088   double dgram_dist_completelinkage(const Array *d, const Dendrogram *c1, const Dendrogram *c2);
00089 
00090   void         dgram_print( Dendrogram *t );
00091   void         dgram_print_node( Dendrogram *t );
00092   void         dgram_preorder( const Dendrogram *t, int *vals, int *n );
00093   Dendrogram*  dgram_init(int val, Dendrogram *left, Dendrogram *right);
00094   void         dgram_free(Dendrogram *t);
00095   Dendrogram*  dgram_get_deepest( Dendrogram *c ); 
00096   int          dgram_num_leaves( const Dendrogram *t );
00097   Array*       dgram_to_matlab( const Dendrogram *dgram );
00098 
00099 #ifdef __cplusplus
00100 }
00101 #endif
00102 
00103 
00104 #endif

Generated on Fri Jun 25 2010 14:10:16 for libeegtools by  doxygen 1.7.0