Using the spectrum function in igraph for R

Hi. I’m trying to use the spectrum function in iGraph for R. Spectrum(.) in its default form extracts the leading or maximum eigenvalue for a matrix. I want to use this eigenvalue to guide the choice of alpha in the alpha_centrality (.) function. In theory, an alpha that is less than the reciprocal of the leading eigenvalue of the matrix will yield meaningful values for the alpha centralities. But you need the leading eigenvalue first, and that’s where spectrum(.) comes in. (This is my latest attempt to use the alpha_centrality(.) function!)

Chalk this up to my inexperience, but how do you access the output from spectrum(.)? What is it called? Apparently, this output is a list, crypically referred to as containing three objects. I’m guessing that the objects are the input data frame, the leading eigenvalue, and the associated eigenvector. But what is the list called and how do I examine the output? I know how to print a list and objects within it.

Here’s an example:

> g <- sample_gnm(5,8)
> sp <- spectrum(g)

Now evaluate sp and look at the output. It should be quite self-explanatory. sp$values gives you the leading eigenvalue.

Thanks for this very helpful advice. A program that extracts the leading eigenvalues and then passes their reciprocal to the alpha_centrality(.) function might help users of iGraph for R for some applications. For instance, this would be useful if you have to execute alpha_centrality on many different networks. My understanding is that alpha_centrality requires a number for the alpha parameter, like 0.25.

Again thanks for your help.