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.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 WritableDataStore<D> |
lambda
The values of the function Lambda of the pointer representation.
|
private static Logging |
logger
The logger for this class.
|
private Integer |
minclusters
Minimum number of clusters to extract
|
private WritableDataStore<DBID> |
pi
The values of the function Pi of the pointer representation.
|
static OptionID |
SLINK_MINCLUSTERS_ID
The minimum number of clusters to extract
|
DISTANCE_FUNCTION_ID
Constructor and Description |
---|
SLINK(DistanceFunction<? super O,D> distanceFunction,
Integer minclusters)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private Cluster<DendrogramModel<D>> |
createParent(String name,
Cluster<DendrogramModel<D>> leftChild,
Cluster<DendrogramModel<D>> rightChild,
D distance,
ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier) |
private Clustering<Model> |
extractClusters_erich(DBIDs ids,
DataStore<DBID> pi,
DataStore<D> lambda,
int minclusters)
Extract all clusters from the pi-lambda-representation.
|
private Clustering<DendrogramModel<D>> |
extractClusters(DBIDs ids,
DataStore<DBID> pi,
DataStore<D> 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>> |
lastAncestor(Cluster<DendrogramModel<D>> cluster,
ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier)
Determines recursively the last ancestor of the specified cluster.
|
private DBID |
lastObjectInCluster(DBID id,
D stopdist,
DataStore<DBID> pi,
DataStore<D> lambda) |
private Cluster<DendrogramModel<D>> |
root(Map<DBID,ModifiableDBIDs> cluster_ids,
Map<DBID,D> cluster_distances,
DataStore<DBID> pi,
DataStore<D> lambda,
ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier,
FiniteProgress progress) |
Result |
run(Database database,
Relation<O> relation)
Performs the SLINK algorithm on the given database.
|
private void |
step1(DBID newID)
First step: Initialize P(id) = id, L(id) = infinity.
|
private void |
step2(DBID newID,
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 |
step3(DBID newID,
DBIDs processedIDs,
WritableDataStore<D> m)
Third step: Determine the values for P and L
|
private void |
step4(DBID newID,
DBIDs processedIDs)
Fourth step: Actualize the clusters if necessary
|
getDistanceFunction
makeParameterDistanceFunction, run
private static final Logging logger
public static final OptionID SLINK_MINCLUSTERS_ID
private WritableDataStore<DBID> pi
private WritableDataStore<D extends Distance<D>> lambda
private Integer minclusters
public SLINK(DistanceFunction<? super O,D> distanceFunction, Integer minclusters)
distanceFunction
- Distance functionminclusters
- Minimum clusters to extract. Can be nullpublic Result run(Database database, Relation<O> relation)
private void step1(DBID newID)
newID
- the id of the object to be inserted into the pointer
representationprivate void step2(DBID newID, DBIDs processedIDs, DistanceQuery<O,D> distFunc, WritableDataStore<D> m)
newID
- the id of the object to be inserted into the pointer
representationprocessedIDs
- the already processed idsdistFunc
- Distance function to useprivate void step3(DBID newID, DBIDs processedIDs, WritableDataStore<D> m)
newID
- the id of the object to be inserted into the pointer
representationprocessedIDs
- the already processed idsprivate void step4(DBID newID, DBIDs processedIDs)
newID
- the id of the current objectprocessedIDs
- the already processed idsprivate DBID lastObjectInCluster(DBID id, D stopdist, DataStore<DBID> pi, DataStore<D> lambda)
private Clustering<DendrogramModel<D>> extractClusters(DBIDs ids, DataStore<DBID> pi, DataStore<D> lambda, int minclusters)
ids
- Object ids to processpi
- Pi storelambda
- Lambda storeminclusters
- Minimum number of clusters to extractprivate Cluster<DendrogramModel<D>> root(Map<DBID,ModifiableDBIDs> cluster_ids, Map<DBID,D> cluster_distances, DataStore<DBID> pi, DataStore<D> lambda, ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier, FiniteProgress progress)
private Cluster<DendrogramModel<D>> lastAncestor(Cluster<DendrogramModel<D>> cluster, ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier)
cluster
- the childhier
- the cluster hierarchyprivate Cluster<DendrogramModel<D>> createParent(String name, Cluster<DendrogramModel<D>> leftChild, Cluster<DendrogramModel<D>> rightChild, D distance, ModifiableHierarchy<Cluster<DendrogramModel<D>>> hier)
private Clustering<Model> extractClusters_erich(DBIDs ids, DataStore<DBID> pi, DataStore<D> lambda, int minclusters)
ids
- Object ids to processpi
- Pi storelambda
- Lambda storeminclusters
- Minimum number of clusters to extractpublic TypeInformation[] getInputTypeRestriction()
AbstractAlgorithm
getInputTypeRestriction
in interface Algorithm
getInputTypeRestriction
in class AbstractAlgorithm<Result>
protected Logging getLogger()
AbstractAlgorithm
getLogger
in class AbstractAlgorithm<Result>