Katz centrality

Eigenvector centrality cannot be calculated for a disconnected graph. Even though it can be calculated for each connected subgraph, the values cannot be compared across subgraphs. It is said that Katz centrality overcomes this problem. I did not find any function for Katz centrality in Python igraph. Is it possible to calculate Katz centrality using Python igraph?

I would phrase this as: is it not meaningful for disconnected graphs.

Currently, there is no function for this. The feature request is here:

That said, calculating it is relatively easy with any linear algebra package. You simply need to solve

(I - \alpha A) x = \beta

One issue with Katz centrality is the finicky choice of \alpha. I recommend reading up on this topic in a textbook, for example Newman’s book https://academic.oup.com/book/27884 I do not recommend relying on Wikipedia—the article on this topic is quite bad.

\alpha should be less than 1/\lambda, where \lambda is the principal eigenvalue of the adjacency matrix. As \alpha approaches 1/\lambda, the Katz centrality approaches the eigenvector centrality. In this sense, Katz centrality doesn’t truly resolve the issues with eigenvector centrality. If \alpha is close to 1/\lambda, all but the scores in the largest component will be close to zeros.

Given the need to do all these linear algebra calculations, you might actually be better off using a linear algebra package than a network analysis package.

Thank you very much for the reply. I hope the wish will come true. It has been there for more than 3 years.

Here’s a simple solution using igraph and scipy:

def katz(graph, alpha, beta = 1.0):
    A = graph.get_adjacency_sparse().transpose();
    A = scipy.sparse.identity(graph.vcount()) - alpha * A
    if numpy.isscalar(beta):
        beta = numpy.full(graph.vcount(), beta)
    return scipy.sparse.linalg.spsolve(A, beta)

(Sorry about my bad Python.)

This is straightforward when having access to an advanced linear algebra library. It’s more complicated to program it from scratch, unless using a naive power iteration. This is one reason why it’s not yet in igraph.