Hi everyone! Thanks for the great package. I’ve been having trouble understanding why I get full 0s as the eigenvector centrality of one of the directed networks I’m studying, even when I restrict it to the largest strongly connected component. I’ve created a link for its adjacency matrix (235x235) and have the full code that outputs my results below:
# Loads igraph
library(igraph)
# Imports the CSV File
url <- "https://www.dropbox.com/scl/fi/j3x6cz8nkdglsolvoe4wj/adj_matrix.csv?rlkey=v2grsi11vanj94a88akr4psj5&dl=1"
adj_matrix <- read.csv(url, header = TRUE)
# Converts network to an igraph Object
g <- graph_from_adjacency_matrix(as.matrix(adj_matrix), mode = "directed")
# Identifies Largest Weakly Connected Component
weak_components <- components(g, mode = "weak")
largest_weak_component <- induced_subgraph(g, which(weak_components$membership == which.max(weak_components$csize)))
cat("Size of Largest Weakly Connected Component:", length(V(largest_weak_component)), "\n")
# Calculates Eigenvector Centrality for largest Weakly Connected Component
weak_eigen_centrality <- eigen_centrality(largest_weak_component, directed = TRUE)$vector
print("Eigenvector Centrality (Weakly Connected):")
print(weak_eigen_centrality)
# Identifies Largest Strongly Connected Component
strong_components <- components(g, mode = "strong")
largest_strong_component <- induced_subgraph(g, which(strong_components$membership == which.max(strong_components$csize)))
cat("Size of Largest Strongly Connected Component:", length(V(largest_strong_component)), "\n")
# Calculates Eigenvector Centrality for largest Strongly Connected Component
strong_eigen_centrality <- eigen_centrality(largest_strong_component, directed = TRUE)$vector
print("Eigenvector Centrality (Strongly Connected):")
print(strong_eigen_centrality)
The result is all 0s for both the weakly connected and the strongly connected case. I believe this shouldn’t happen, right? My understanding is that there should be variation in the eigenvector centrality in this case. Could you help in checking what I’m doing wrong?
(Output for both cases, just for completeness:)