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") @Alias(value={"de.lmu.ifi.dbs.elki.algorithm.clustering.SLINK","clustering.SLINK","SLINK","single-link","single-linkage"}) public class SLINK<O,D extends Distance<D>> extends AbstractDistanceBasedAlgorithm<O,D,PointerHierarchyRepresentationResult<D>> implements HierarchicalClusteringAlgorithm<D>
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 |
---|---|
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.
|
DISTANCE_FUNCTION_ID
Constructor and Description |
---|
SLINK(DistanceFunction<? super O,D> distanceFunction)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
D |
getDistanceFactory()
Return the distance type that will be used by the algorithm.
|
TypeInformation[] |
getInputTypeRestriction()
Get the input type restriction used for negotiating the data query.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
PointerHierarchyRepresentationResult<D> |
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
|
getDistanceFunction
makeParameterDistanceFunction, run
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
run
private static final Logging LOG
public SLINK(DistanceFunction<? super O,D> distanceFunction)
distanceFunction
- Distance functionpublic PointerHierarchyRepresentationResult<D> 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 idspublic D getDistanceFactory()
HierarchicalClusteringAlgorithm
getDistanceFactory
in interface HierarchicalClusteringAlgorithm<D extends Distance<D>>
public TypeInformation[] getInputTypeRestriction()
AbstractAlgorithm
getInputTypeRestriction
in interface Algorithm
getInputTypeRestriction
in class AbstractAlgorithm<PointerHierarchyRepresentationResult<D extends Distance<D>>>
protected Logging getLogger()
AbstractAlgorithm
getLogger
in class AbstractAlgorithm<PointerHierarchyRepresentationResult<D extends Distance<D>>>