This funtion provides a table contaning various network attributes
top3Hub <- function(graph.object){
aa <- authority.score(graph.object)$vector
bb <- V(graph.object)
dd <- list(bb,round(aa,3))
df <- data.frame(matrix(unlist(dd), nrow=length(V(graph.object)), byrow=F))
ordf <- df[with(df, order(-df[,2])), ]
Hub <- ordf[1:3,1]
grabHub <- paste(Hub,collapse=";")
HUbV <- ordf[1:3,2]
grabHubV <- paste(HUbV,collapse=";")
grab <- c(grabHub,grabHubV)
return(grab)
}
Example
library(devtools)
install_github("ravinpoudel/myFunctions")
library(myFunctions)
library(igraph)
g <- erdos.renyi.game(10, 1/5)
top3 <- top3Hub(g)
top3
## [1] "10;3;7" "1;0.971;0.908"