Package elki.clustering.hierarchical
Class Anderberg.Instance
- java.lang.Object
-
- elki.clustering.hierarchical.AGNES.Instance
-
- elki.clustering.hierarchical.Anderberg.Instance
-
- Direct Known Subclasses:
HACAM.Instance
public static class Anderberg.Instance extends AGNES.Instance
Main worker instance of Anderberg's algorithm.- Author:
- Erich Schubert
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
findBest(double[] scratch, double[] bestd, int[] besti, int j)
Find the best in a row of the triangular matrix.protected int
findMerge()
Perform the next merge step.protected static void
initializeNNCache(double[] scratch, double[] bestd, int[] besti)
Initialize the NN cache.protected void
merge(double mindist, int x, int y)
Execute the cluster merge.ClusterMergeHistory
run(ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder)
Run the main algorithm.protected static void
updateCache(double[] scratch, double[] bestd, int[] besti, int x, int y, int j, double d)
Update the cache.protected void
updateMatrix(double mindist, int x, int y, int sizex, int sizey)
Update the scratch distance matrix.-
Methods inherited from class elki.clustering.hierarchical.AGNES.Instance
shrinkActiveSet
-
-
-
-
Constructor Detail
-
Instance
public Instance(Linkage linkage)
Constructor.- Parameters:
linkage
- Linkage method
-
-
Method Detail
-
run
public ClusterMergeHistory run(ClusterDistanceMatrix mat, ClusterMergeHistoryBuilder builder)
Description copied from class:AGNES.Instance
Run the main algorithm.- Overrides:
run
in classAGNES.Instance
- Parameters:
mat
- Distance matrixbuilder
- Result builder- Returns:
- Cluster history
-
initializeNNCache
protected static void initializeNNCache(double[] scratch, double[] bestd, int[] besti)
Initialize the NN cache.- Parameters:
scratch
- Scratch spacebestd
- Best distancebesti
- Best index
-
findMerge
protected int findMerge()
Perform the next merge step.Due to the cache, this is now O(n) each time, instead of O(n*n).
- Overrides:
findMerge
in classAGNES.Instance
- Returns:
- x, for shrinking the working set.
-
merge
protected void merge(double mindist, int x, int y)
Description copied from class:AGNES.Instance
Execute the cluster merge.- Overrides:
merge
in classAGNES.Instance
- Parameters:
mindist
- Distance that was used for mergingx
- First matrix positiony
- Second matrix position
-
updateMatrix
protected void updateMatrix(double mindist, int x, int y, int sizex, int sizey)
Description copied from class:AGNES.Instance
Update the scratch distance matrix.- Overrides:
updateMatrix
in classAGNES.Instance
- Parameters:
mindist
- Minimum distancex
- First matrix positiony
- Second matrix positionsizex
- Old size of first clustersizey
- Old size of second cluster
-
updateCache
protected static void updateCache(double[] scratch, double[] bestd, int[] besti, int x, int y, int j, double d)
Update the cache.- Parameters:
scratch
- Scratch matrixbestd
- Best distancebesti
- Best indexx
- First clustery
- Second cluster,y < x
j
- Updated value d(y, j)d
- New distance
-
findBest
protected static void findBest(double[] scratch, double[] bestd, int[] besti, int j)
Find the best in a row of the triangular matrix.- Parameters:
scratch
- Scratch matrixbestd
- Best distances cachebesti
- Best indexes cachej
- Row to update
-
-