
O - the type of DatabaseObject the algorithm is applied onD - the type of Distance used@Title(value="SLINK: Single Link Clustering") @Description(value="Hierarchical clustering algorithm based on single-link connectivity.") @Reference(authors="R. Sibson", title="SLINK: An optimally efficient algorithm for the single-link cluster method", booktitle="The Computer Journal 16 (1973), No. 1, p. 30-34.", url="http://dx.doi.org/10.1093/comjnl/16.1.30") public class SLINK<O,D extends Distance<D>> extends AbstractDistanceBasedAlgorithm<O,D,Result>
Reference: R. Sibson: SLINK: An optimally efficient algorithm for the
single-link cluster method.
In: The Computer Journal 16 (1973), No. 1, p. 30-34.
| Modifier and Type | Class and Description |
|---|---|
private static class |
SLINK.CompareByDoubleLambda
Order a DBID collection by the lambda value.
|
private static class |
SLINK.CompareByLambda<D extends Distance<D>>
Order a DBID collection by the lambda value.
|
static class |
SLINK.Parameterizer<O,D extends Distance<D>>
Parameterization class.
|
| Modifier and Type | Field and Description |
|---|---|
private static Logging |
LOG
The logger for this class.
|
private int |
minclusters
Minimum number of clusters to extract
|
DISTANCE_FUNCTION_ID| Constructor and Description |
|---|
SLINK(DistanceFunction<? super O,D> distanceFunction,
int minclusters)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private Clustering<DendrogramModel<D>> |
extractClusters(DBIDs ids,
DBIDDataStore pi,
DataStore<D> lambda,
int minclusters)
Extract all clusters from the pi-lambda-representation.
|
private Clustering<DendrogramModel<D>> |
extractClustersDouble(DBIDs ids,
DBIDDataStore pi,
DoubleDistanceDataStore lambda,
int minclusters)
Extract all clusters from the pi-lambda-representation.
|
TypeInformation[] |
getInputTypeRestriction()
Get the input type restriction used for negotiating the data query.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
private Cluster<DendrogramModel<D>> |
makeCluster(DBIDRef lead,
D depth,
DBIDs members,
ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier)
Make the cluster for the given object
|
Result |
run(Database database,
Relation<O> relation)
Performs the SLINK algorithm on the given database.
|
private void |
step1(DBIDRef id,
WritableDBIDDataStore pi,
WritableDataStore<D> lambda)
First step: Initialize P(id) = id, L(id) = infinity.
|
private void |
step1double(DBIDRef id,
WritableDBIDDataStore pi,
WritableDoubleDistanceDataStore lambda)
First step: Initialize P(id) = id, L(id) = infinity.
|
private void |
step2(DBIDRef id,
DBIDs processedIDs,
DistanceQuery<O,D> distFunc,
WritableDataStore<D> m)
Second step: Determine the pairwise distances from all objects in the
pointer representation to the new object with the specified id.
|
private void |
step2double(DBIDRef id,
DBIDs processedIDs,
Relation<? extends O> relation,
PrimitiveDoubleDistanceFunction<? super O> distFunc,
WritableDoubleDistanceDataStore m)
Second step: Determine the pairwise distances from all objects in the
pointer representation to the new object with the specified id.
|
private void |
step3(DBIDRef id,
WritableDBIDDataStore pi,
WritableDataStore<D> lambda,
DBIDs processedIDs,
WritableDataStore<D> m)
Third step: Determine the values for P and L
|
private void |
step3double(DBIDRef id,
WritableDBIDDataStore pi,
WritableDoubleDistanceDataStore lambda,
DBIDs processedIDs,
WritableDoubleDistanceDataStore m)
Third step: Determine the values for P and L
|
private void |
step4(DBIDRef id,
WritableDBIDDataStore pi,
WritableDataStore<D> lambda,
DBIDs processedIDs)
Fourth step: Actualize the clusters if necessary
|
private void |
step4double(DBIDRef id,
WritableDBIDDataStore pi,
WritableDoubleDistanceDataStore lambda,
DBIDs processedIDs)
Fourth step: Actualize the clusters if necessary
|
getDistanceFunctionmakeParameterDistanceFunction, runprivate static final Logging LOG
private int minclusters
public SLINK(DistanceFunction<? super O,D> distanceFunction, int minclusters)
distanceFunction - Distance functionminclusters - Minimum clusters to extract. Can be -1.public Result run(Database database, Relation<O> relation)
private void step1(DBIDRef id, WritableDBIDDataStore pi, WritableDataStore<D> lambda)
id - the id of the object to be inserted into the pointer
representationpi - Pi data storelambda - Lambda data storeprivate void step2(DBIDRef id, DBIDs processedIDs, DistanceQuery<O,D> distFunc, WritableDataStore<D> m)
id - the id of the object to be inserted into the pointer
representationprocessedIDs - the already processed idsm - Data storedistFunc - Distance function to useprivate void step3(DBIDRef id, WritableDBIDDataStore pi, WritableDataStore<D> lambda, DBIDs processedIDs, WritableDataStore<D> m)
id - the id of the object to be inserted into the pointer
representationpi - Pi data storelambda - Lambda data storeprocessedIDs - the already processed idsm - Data storeprivate void step4(DBIDRef id, WritableDBIDDataStore pi, WritableDataStore<D> lambda, DBIDs processedIDs)
id - the id of the current objectpi - Pi data storelambda - Lambda data storeprocessedIDs - the already processed idsprivate void step1double(DBIDRef id, WritableDBIDDataStore pi, WritableDoubleDistanceDataStore lambda)
id - the id of the object to be inserted into the pointer
representationpi - Pi data storelambda - Lambda data storeprivate void step2double(DBIDRef id, DBIDs processedIDs, Relation<? extends O> relation, PrimitiveDoubleDistanceFunction<? super O> distFunc, WritableDoubleDistanceDataStore m)
id - the id of the object to be inserted into the pointer
representationprocessedIDs - the already processed idsm - Data storerelation - Data relationdistFunc - Distance function to useprivate void step3double(DBIDRef id, WritableDBIDDataStore pi, WritableDoubleDistanceDataStore lambda, DBIDs processedIDs, WritableDoubleDistanceDataStore m)
id - the id of the object to be inserted into the pointer
representationpi - Pi data storelambda - Lambda data storeprocessedIDs - the already processed idsm - Data storeprivate void step4double(DBIDRef id, WritableDBIDDataStore pi, WritableDoubleDistanceDataStore lambda, DBIDs processedIDs)
id - the id of the current objectpi - Pi data storelambda - Lambda data storeprocessedIDs - the already processed idsprivate Clustering<DendrogramModel<D>> extractClusters(DBIDs ids, DBIDDataStore pi, DataStore<D> lambda, int minclusters)
ids - Object ids to processpi - Pi storelambda - Lambda storeminclusters - Minimum number of clusters to extractprivate Clustering<DendrogramModel<D>> extractClustersDouble(DBIDs ids, DBIDDataStore pi, DoubleDistanceDataStore lambda, int minclusters)
ids - Object ids to processpi - Pi storelambda - Lambda storeminclusters - Minimum number of clusters to extractprivate Cluster<DendrogramModel<D>> makeCluster(DBIDRef lead, D depth, DBIDs members, ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier)
lead - Leading objectdepth - Linkage depthmembers - Member objectshier - Cluster hierarchypublic TypeInformation[] getInputTypeRestriction()
AbstractAlgorithmgetInputTypeRestriction in interface AlgorithmgetInputTypeRestriction in class AbstractAlgorithm<Result>protected Logging getLogger()
AbstractAlgorithmgetLogger in class AbstractAlgorithm<Result>