scgGrouping(V, nt, mtype = c("symmetric", "laplacian",
"stochastic"), algo = c("optimum", "interv_km",
"interv","exact_scg"), p = NULL, maxiter = 100)
V
).length(ev)
. When algo
= nt
contains the number of groups used to partition each eigenvector
separately. When algo
nrow(V)
. p
is the stationary probability distribution
of a Markov chain when mtype
= algo
= nrow(V)
integers giving the group label of each
object (vertex) in the partition.V
. The running time of this algorithm is
$O(\max nt \cdot m^2)$ for the symmetric and
laplacian matrix problems (i.e. when mtype
is
V
.
In all three cases, the memory usage is $O(m^2)$. The algorithms nt[i]
constant-size bins are used to partition V[,i]
. When
algo
=
Once a minimizing partition (either exact or approximate) has been
found for each eigenvector, the final grouping is worked out as
follows: two vertices are grouped together in the final partition if
they are grouped together in each minimizing partition. In general the
size of the final partition is not known in advance when
ncol(V)
>1.
Finally, the algorithm
scg
,
scgNormEps
# eigenvectors of a random symmetric matrix
M <- matrix(rexp(10^6), 10^3, 10^3)
M <- (M + t(M))/2
V <- eigen(M, symmetric=TRUE)$vectors[,c(1,2)]
# displays size of the groups in the final partition
gr <- scgGrouping(V, nt=c(2,3))
col <- rainbow(max(gr))
plot(table(gr), col=col, main="Group size", xlab="group", ylab="size")
## comparison with the grouping obtained by kmeans
## for a partition of same size
gr.km <- kmeans(V,centers=max(gr), iter.max=100, nstart=100)$cluster
op <- par(mfrow=c(1,2))
plot(V[,1], V[,2], col=col[gr],
main = "SCG grouping",
xlab = "1st eigenvector",
ylab = "2nd eigenvector")
plot(V[,1], V[,2], col=col[gr.km],
main = "K-means grouping",
xlab = "1st eigenvector",
ylab = "2nd eigenvector")
par(op)
## kmeans disregards the first eigenvector as it
## spreads a much smaller range of values than the second one
### comparing optimal and k-means solutions
### in the one-dimensional case.
x <- rexp(2000, 2)
gr.true <- scgGrouping(cbind(x), 100)
gr.km <- kmeans(x, 100, 100, 300)$cluster
scgNormEps(cbind(x), gr.true)
scgNormEps(cbind(x), gr.km)
Run the code above in your browser using DataLab