├── LICENSE ├── Makefile ├── README.md ├── agglomerate.c ├── ahc.png ├── ahc_tree.png └── example.txt /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Gagarine Yaikhom 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | agglomerate: agglomerate.c 2 | gcc -std=c99 -o agglomerate agglomerate.c -lm 3 | 4 | clean: 5 | rm -f agglomerate 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Agglomerative Hierarchical Clustering 2 | 3 | Implements the 4 | [Agglomerative Hierarchical Clustering](http://en.wikipedia.org/wiki/Hierarchical_clustering) 5 | algorithm. 6 | 7 | ## Usage 8 | 9 | To run the clustering program, you need to supply the following 10 | parameters on the command line: 11 | 12 | * Input file that contains the items to be clustered. 13 | * Number of disjointed clusters that we wish to extract. 14 | * _Linkage criteria_ to use when calculating the _distance metric_. 15 | 16 | * `s` - Single linkage (default) 17 | * `c` - Complete linkage 18 | * `a` - Average linkage 19 | * `t` - Centroid linkage 20 | 21 | For instance, the following is an example run: 22 | 23 | $ ./agglomerate example.txt 3 s 24 | 25 | In this example, we are running the hierarchical agglomerative 26 | clustering on the items in the input file `example.txt`. We are asking 27 | the program to generate `3` disjointed clusters using the 28 | _single-linkage_ distance metric. 29 | 30 | ### The input file 31 | 32 | The input file contains the items to be clustered. 33 | 34 | 35 |