cluster.dist: Clustering a Sparse Symmetric Distance Matrix

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/cluster.r

Description

Compute a clustering on a sparse symmetric distance matrix using graph cutting.

Usage

1

Arguments

x

an object of class dist.

beta

the distance threshold.

Details

This function computes a clustering on an object of class dist by cutting the graph induced by the threshold beta into all disconnected subgraphs (the clusters). Two nodes are connected by a link if their distance is below the specified threshold. Note that the threshold is not strict, i.e. >=.

Note that distances of value NA and NaN are ignored. This is not strictly correct but avoids computing 2^k possible solutions if there are k NA values.

The time complexity is O(n^2) with n the number of rows/columns.

Value

A factor of cluster labels (indexed 1,2,...,k).

Note

Fixme: can the time complexity be improved?

Author(s)

Christian Buchta

See Also

dist and sdists for distance computation.

Examples

1
2
3
4
5
6
7
8
9
## 3 clusters (1 = connected)
x <- matrix(c(1,1,0,0,0,0,
	      1,1,0,0,0,0,
	      0,0,1,1,0,0,
	      0,0,1,1,0,0,
	      0,0,0,0,1,1,
	      0,0,0,0,1,1), ncol=6)
c <- cluster.dist(as.dist(!x), beta = 0) # invert and note that 0 >= 0
c

Example output

Loading required package: grid
Loading required package: proxy

Attaching package: 'proxy'

The following objects are masked from 'package:stats':

    as.dist, dist

The following object is masked from 'package:base':

    as.matrix

[1] 1 1 2 2 3 3
Levels: 1 2 3

cba documentation built on May 2, 2019, 1:39 p.m.

Related to cluster.dist in cba...