Home > database >  Change default ARPACK options for eigenvalue calculation for igraph package
Change default ARPACK options for eigenvalue calculation for igraph package

Time:06-11

According to the CRAN igraph docs, the arpack_defaults() provides the default values. I should be able to supply a named list to override the defaults, but I am unable to get the syntax correct. It works for spectrum() but fails for centr_eigen(), eigen_centrality(), or evcent()

library(igraph)

# Create and Print Graph
bb <- graph_from_literal(E-D-A-B, A-C)
print(bb)
#IGRAPH dc36067 UN-- 5 4 -- 
#  attr: name (v/c)
#  edges from dc36067 (vertex names):
#[1] E--D D--A A--B A--C

# Changing the ARPACK option by providing a named list works here
spectrum(bb, which = list(pos = "LA"))$options$which   #[1] "LA"
spectrum(bb, which = list(pos = "LM"))$options$which   #[1] "LM"

# Functions below are not using the provided "LM" & instead using default "LA"
centr_eigen(bb, options = list(which = "LM"))$options$which      #[1] "LA"
eigen_centrality(bb, options = list(which = "LM"))$options$which #[1] "LA"
evcent(bb, options = list(which = "LM"))$options$which           #[1] "LA"

CodePudding user response:

The ARPACK options can control two things in the most general case:

  1. What to compute
  2. How to compute it

Of course, eigen_centrality() computes a very specific thing: the eigenvector centrality, defined as the components of the eigenvector associated with the largest eigenvalue. There is no room to change what it computes, only how it computes it. Elements of the ARPACK options controlling what to compute are overwritten.

If you need general eigenvalue computations with the adjacency matrix, use spectrum(). Note that even in this case, the which element of the ARPACK options will be overwritten by what you provide in the which argument. If you need eigenvector centrality, use eigen_centrality().

  • Related