Dear all,
I have a list of network files for which I want to find the network neighborhoods(order=1) of each of the nodes of these networks. And then store all the subgraphs hence obtained in separate files.Another thing that I would like to do is to name them in such a way so as to figure out from which network file have they originated. But what I am getting as output is an empty file.Here's my code :
library("igraph")
path <- "path/to/network/files/"
files <- dir(path)
for(i in 1:length(files)){
file <- paste(path,"/",files[i],sep="")
g<-read.graph(file,format="ncol", directed=FALSE, weights=FALSE)
g<-simplify(g)
subgraphs<-graph.neighborhood(g,1,nodes=V(g))
for(j in subgraphs){
gr_name <- paste(file,j,sep="")
write.graph(gr,"/path/tonetwork/files/gr_name.txt",format="ncol")
}}
Attached herewith are a couple of network files. Can anyone tell where am I going wrong? Thanks in advance.
Here's my sessionInfo():
R version 2.11.0 (2010-04-22)
x86_64-redhat-linux-gnu
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] igraph_0.5.3
loaded via a namespace (and not attached):
[1] tools_2.11.0
Regards,
Anupam Sinha