Package elki.clustering.hierarchical
Class ClusterDistanceMatrix
- java.lang.Object
-
- elki.clustering.hierarchical.ClusterDistanceMatrix
-
public class ClusterDistanceMatrix extends java.lang.Object
Shared code for algorithms that work on a pairwise cluster distance matrix.Note that this requires O(n²) memory (and often O(n³) runtime).
This class bridges the gap from the relational (indexed by identifiers) and the matrix view (indexed by integers 0...n-1).
While this will usually store (merge-) distances when clustering, it can store arbitrary doubles.
- Since:
- 0.7.5
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description int[]
clustermap
Mapping from positions to cluster numbersdouble[]
matrix
Distance matrix (modifiable).int
size
Number of rows/columns.
-
Constructor Summary
Constructors Constructor Description ClusterDistanceMatrix(int size)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
get(int x, int y)
Get a value from the (upper triangular) distance matrix.static int
triangleSize(int x)
Compute the size of a complete x by x triangle (minus diagonal)
-
-
-
Method Detail
-
triangleSize
public static int triangleSize(int x)
Compute the size of a complete x by x triangle (minus diagonal)- Parameters:
x
- Offset- Returns:
- Size of complete triangle
-
get
public double get(int x, int y)
Get a value from the (upper triangular) distance matrix.Note: in many cases, linear iteration over the matrix will be faster than repeated calls to this method!
- Parameters:
x
- First objecty
- Second object- Returns:
- Distance
-
-