21 lines
484 B
R

katz.cent <- function(A, alpha=NULL, beta=NULL){ #NULL sets the default value
if (class(A) == 'igraph'){
#Error checking. Turn into adj matrix.
A <- get.adjacency(A)
}
lam.dom <- eigen(A)$values[1] #dom eigenvec
if (is.null(alpha)){
alpha <- 0.9 * (1/lam.dom) #Set alpha to 90% of max allowed
}
n <- nrow(A)
if (is.null(beta)){
beta <- matrix(rep(1/n, n),ncol=1)
}
#Katz scores
scores <- solve(diag(n) - alpha*A,beta)
return(scores)
}