2
* This file is licensed to You under the "Simplified BSD License".
3
* You may not use this software except in compliance with the License.
4
* You may obtain a copy of the License at
6
* http://www.opensource.org/licenses/bsd-license.php
8
* See the COPYRIGHT file distributed with this work for information
9
* regarding copyright ownership.
11
package ch.usi.inf.sape.hac.agglomeration;
15
* The "complete", "maximum", "clique",
16
* "furthest neighbor", or "furthest distance" method is a graph-based approach.
18
* The distance between two clusters is calculated as the largest distance
19
* between two objects in opposite clusters.
20
* This method tends to produce well separated, small, compact spherical clusters.
21
* The cluster space is dilated.
22
* [The data analysis handbook. By Ildiko E. Frank, Roberto Todeschini]
24
* This method tends to produce compact clusters. Outliers are given more weight with this method.
25
* It is generally a good choice if the clusters are far apart in feature space, but not good if the data are noisy.
26
* @see http://www.stanford.edu/~maureenh/quals/html/ml/node75.html
28
* The general form of the Lance-Williams matrix-update formula:
29
* d[(i,j),k] = ai*d[i,k] + aj*d[j,k] + b*d[i,j] + g*|d[i,k]-d[j,k]|
31
* For the "single linkage" method:
38
* d[(i,j),k] = 0.5*d[i,k] + 0.5*d[j,k] + 0.5*|d[i,k]-d[j,k]|
39
* = 0.5*d[i,k] + 0.5*d[j,k] + | 0.5*d[i,k] - 0.5*d[j,k] |
40
* = d[i,j]<d[j,k] ? 0.5*d[i,k] + 0.5*d[j,k] - 0.5*d[i,k] + 0.5*d[j,k] : 0.5*d[i,k] + 0.5*d[j,k] + 0.5*d[i,k] - 0.5*d[j,k]
41
* = d[i,j]<d[j,k] ? 0.5*d[j,k] + 0.5*d[j,k] : 0.5*d[i,k] + 0.5*d[i,k]
42
* = d[i,j]<d[j,k] ? d[j,k] : d[i,k]
43
* = max( d[i,k] , d[j,k] )
45
* @author Matthias.Hauswirth@usi.ch
47
public final class CompleteLinkage implements AgglomerationMethod {
49
public double computeDissimilarity(final double dik, final double djk, final double dij, final int ci, final int cj, final int ck) {
50
return Math.max(dik, djk);
53
public String toString() {