igraph (version 0.7.0)

graph.eigen: Eigenvalues and eigenvectors of the adjacency matrix of a graph

Description

Calculate selected eigenvalues and eigenvectors of a (supposedly sparse) graph.

Usage

graph.eigen (graph, algorithm = c("arpack", "auto", "lapack", "comp_auto", 
    "comp_lapack", "comp_arpack"), which = list(),
    options = igraph.arpack.default)
igraph.eigen.default

Arguments

graph
The input graph, can be directed or undirected.
algorithm
The algorithm to use. Currently only arpack is implemented, which uses the ARPACK solver. See also arpack.
which
A list to specify which eigenvalues and eigenvectors to calculate. By default the leading (i.e. largest magnitude) eigenvalue and the corresponding eigenvector is calculated.
options
Options for the ARPACK solver. See igraph.arpack.default.

Value

  • Depends on the algorithm used.

    For arpack a list with three entries is returned:

  • optionsSee the return value for arpack for a complete description.
  • valuesNumeric vector, the eigenvalues.
  • vectorsNumeric matrix, with the eigenvectors as columns.

concept

  • Eigenvalues
  • Eigenvectors

Details

The which argument is a list and it specifies which eigenvalues and corresponding eigenvectors to calculate: There are eight options:
  1. Eigenvalues with the largest magnitude. SetpostoLM, andhowmanyto the number of eigenvalues you want.
  2. Eigenvalues with the smallest magnitude. SetpostoSMandhowmanyto the number of eigenvalues you want.
  3. Largest eigenvalues. SetpostoLAandhowmanyto the number of eigenvalues you want.
  4. Smallest eigenvalues. SetpostoSAandhowmanyto the number of eigenvalues you want.
  5. Eigenvalues from both ends of the spectrum. SetpostoBEandhowmanyto the number of eigenvalues you want. Ifhowmanyis odd, then one more eigenvalue is returned from the larger end.
  6. Selected eigenvalues. This is not (yet) implemented currently.
  7. Eigenvalues in an interval. This is not (yet) implemented.
  8. All eigenvalues. This is not implemented yet. The standardeigenfunction does a better job at this, anyway.
Note that ARPACK might be unstable for graphs with multiple components, e.g. graphs with isolate vertices.

See Also

get.adjacency to create a (sparse) adjacency matrix.

Examples

Run this code
## Small example graph, leading eigenvector by default
kite <- graph.famous("Krackhardt_kite")
graph.eigen(kite)[c("values", "vectors")]

## Double check
eigen(get.adjacency(kite, sparse=FALSE))$vectors[,1]

## Should be the same as 'evcent' (but rescaled)
cor(evcent(kite)$vector, graph.eigen(kite)$vectors)

## Smallest eigenvalues
graph.eigen(kite, which=list(pos="SM", howmany=2))$values

Run the code above in your browser using DataCamp Workspace