arpack(func, extra = NULL, sym = FALSE, options = igraph.arpack.default,
env = parent.frame(), complex=!sym)
arpack.unpack.complex(vectors, values, nev)func.TRUE here if it is, since it can
speed up the computation.func will be evaluated.complex=TRUE (the default for non-symmetric
problems), then the matrix is complex.options and
some information about the performed calculation, including an
ARPACK exit code. See the details above.arpackLMw <- Av requires
order $n$ rather than the usual order $n^2$ floating point
operations. Please see
This function is an interface to ARPACK. igraph does not contain all ARPACK routines, only the ones dealing with symmetric and non-symmetric eigenvalue problems using double precision real numbers.
The eigenvalue calculation in ARPACK (in the simplest
case) involves the calculation of the $Av$ product where $A$
is the matrix we work with and $v$ is an arbitrary vector. The
function supplied in the fun argument is expected to perform
this product. If the product can be done efficiently, e.g. if the
matrix is sparse, then arpack is usually able to calculate the
eigenvalues very quickly.
The options argument specifies what kind of calculation to
perform. It is a list with the following members, they correspond
directly to ARPACK parameters. On input it has the following fields:
IGIarpack
directly. (I.e. not needed for evcent,
page.rank, etc.)}
Possible values for symmetric input matrices:
LAnev largest (algebraic)
eigenvalues.}
SAnev smallest (algebraic)
eigenvalues.}
LMnev largest (in magnitude)
eigenvalues.}
SMnev smallest (in magnitude)
eigenvalues.}
BEnev eigenvalues, half
from each end of the spectrum. When nev is odd, compute
one more from the high end than from the low end.}
}Possible values for non-symmetric input matrices:
LMnev eigenvalues of
largest magnitude.}
SMnev eigenvalues of
smallest magnitude.}
LRnev eigenvalues of
largest real part.}
SRnev eigenvalues of
smallest real part.}
LInev eigenvalues of
largest imaginary part.}
SInev eigenvalues of
smallest imaginary part.}evcent, page.rank,
hub.score, leading.eigenvector.community
are some of the functions in igraph which use ARPACK. The ARPACK
homepage is at # Identity matrix
f <- function(x, extra=NULL) x
arpack(f, options=list(n=10, nev=2, ncv=4), sym=TRUE)
# Graph laplacian of a star graph (undirected), n>=2
# Note that this is a linear operation
f <- function(x, extra=NULL) {
y <- x
y[1] <- (length(x)-1)*x[1] - sum(x[-1])
for (i in 2:length(x)) {
y[i] <- x[i] - x[1]
}
y
}
arpack(f, options=list(n=10, nev=1, ncv=3), sym=TRUE)
# double check
eigen(graph.laplacian(graph.star(10, mode="undirected")))Run the code above in your browser using DataLab