# scgSemiProjectors

##### Semi-Projectors

A function to compute the $L$ and $R$ semi-projectors for a given partition of the vertices.

##### Usage

```
scgSemiProjectors(groups, mtype = c("symmetric", "laplacian",
"stochastic"), p = NULL, norm = c("row", "col"),
sparse = getIgraphOpt("sparsematrices"))
```

##### Arguments

- groups
- A vector of
`nrow(X)`

or`vcount(X)`

integers giving the group label of every vertex in the partition. - mtype
- The type of semi-projectors. For now
symmetric ,laplacian andstochastic are available. - p
- A probability vector of length
`length(gr)`

.`p`

is the stationary probability distribution of a Markov chain when`mtype`

=stochastic . This parameter is ignored in all other cases. - norm
- Either
row orcol . If set torow the rows of the Laplacian matrix sum up to zero and the rows of the stochastic sum up to one; otherwise it is the columns. - sparse
- Logical scalar, whether to return sparse matrices.

##### Details

The three types of semi-projectors are defined as follows.
Let $\gamma(j)$ label the group of vertex $j$ in a
partition of all the vertices.
The symmetric semi-projectors are defined as
$$L_{\alpha j}=R_{\alpha j}=
\frac{1}{\sqrt{|\alpha|}}\delta_{\alpha\gamma(j)},$$
the (row) Laplacian semi-projectors as
$$L_{\alpha j}=\frac{1}{|\alpha|}\delta_{\alpha\gamma(j)}\,\,\,\,
\textrm{and}\,\,\,\, R_{\alpha j}=\delta_{\alpha\gamma(j)},$$
and the (row) stochastic semi-projectors as
$$L_{\alpha j}=\frac{p_{1}(j)}{\sum_{k\in\gamma(j)}p_{1}(k)}\,\,\,\,
\textrm{and}\,\,\,\, R_{\alpha j}=\delta_{\alpha\gamma(j)\delta_{\alpha\gamma(j)}},$$
where $p_1$ is the (left) eigenvector associated with the
one-eigenvalue of the stochastic matrix. $L$ and $R$ are
defined in a symmetric way when `norm = col`

. All these
semi-projectors verify various properties described in the
reference.

##### Value

L The semi-projector $L$. R The semi-projector $R$.

##### References

D. Morton de Lachapelle, D. Gfeller, and P. De Los Rios, Shrinking
Matrices while Preserving their Eigenpairs with Application to the
Spectral Coarse Graining of Graphs. Submitted to *SIAM
Journal on Matrix Analysis and Applications*, 2008.

##### See Also

SCG for a detailed introduction. `scg`

,
`scgNormEps`

, `scgGrouping`

##### Examples

```
# compute the semi-projectors and projector for the partition
# provided by a community detection method
g <- barabasi.game(20, m=1.5)
eb <- edge.betweenness.community(g)
memb <- membership(eb)
lr <- scgSemiProjectors(memb)
#In the symmetric case L = R
tcrossprod(lr$R) # same as lr$R %*% t(lr$R)
P <- crossprod(lr$R) # same as t(lr$R) %*% lr$R
#P is an orthogonal projector
isSymmetric(P)
sum( (P %*% P-P)^2 )
## use L and R to coarse-grain the graph Laplacian
lr <- scgSemiProjectors(memb, mtype="laplacian")
L <- graph.laplacian(g)
Lt <- lr$L %*% L %*% t(lr$R)
## or better lr$L \%*\% tcrossprod(L,lr$R)
rowSums(Lt)
```

*Documentation reproduced from package igraph, version 0.6.5-2, License: GPL (>= 2)*