Skip to content

Instantly share code, notes, and snippets.

@ngopal
Created July 29, 2016 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngopal/fc8f54ecd57b32e02f94ca8bf91f9f40 to your computer and use it in GitHub Desktop.
Save ngopal/fc8f54ecd57b32e02f94ca8bf91f9f40 to your computer and use it in GitHub Desktop.
library(igraph)
# Random Graph Set Space Exploration
plot_densityXsize <- function(dens,size) {
numer = 1;
par(mfrow=c(length(dens), length(size)))
for (d in dens) {
for (s in size) {
cat(paste("rg",numer," <- random.graph.game(",s,",",d,")",sep=''), '\n')
assign(paste("rg",numer,sep=''),eval(parse(text=paste("random.graph.game(",s,",",d,")",sep=''))), envir = .GlobalEnv)
plot(random.graph.game(s, d), vertex.size=8, vertex.label=NA, vertex.color="black")
numer = numer + 1;
}
}
}
plot_hist <- function(dens,size,func,title) {
numer = 1;
par(mfrow=c(length(dens), length(size)))
for (d in dens) {
for (s in size) {
if (title == "eigenvec") {
hist(func(eval(parse(text=paste("rg",numer,sep=''))), normalized = TRUE)$vector, main=paste(title,"\ns:",s," d:",d,sep=''), xlab=NA)
numer = numer + 1;
}
else {
hist(func(eval(parse(text=paste("rg",numer,sep=''))), normalized = TRUE)$res, main=paste(title,"\ns:",s," d:",d,sep=''), xlab=NA)
numer = numer + 1;
}
}
}
}
plot_densityXsize(c(0.01, 0.05, 0.1, 0.15), c(10,25,50,75,100))
plot_hist(c(0.01, 0.05, 0.1, 0.15), c(10,25,50,75,100), centralization.betweenness, "betweenness")
plot_hist(c(0.01, 0.05, 0.1, 0.15), c(10,25,50,75,100), centralization.closeness, "closeness")
plot_hist(c(0.01, 0.05, 0.1, 0.15), c(10,25,50,75,100), centralization.degree, "degree")
plot_hist(c(0.01, 0.05, 0.1, 0.15), c(10,25,50,75,100), centralization.evcent, "eigenvec")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment