igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Re: network neighborhood


From: anupam sinha
Subject: Re: [igraph] Re: network neighborhood
Date: Mon, 4 Oct 2010 12:05:45 +0530

Hi Gabor,
                    Thanks a lot for your reply. The program is working fine but I am unable to understand the output.Suppose one has following edgelist file of an undirected network:

A - B
A - C
A - D
C - E
C - F

Now if I run graph.neighborhood on this file shouldn't I get two subgraphs

A-B       and   A-C
A-C                C-E
A-D                C-F

One more thing is that I am unable to send any attachments to the igraph-help mail group . The mail simply bounces back. Thanks in advance for any suggestions.

Regards,

Anupam


On Fri, Oct 1, 2010 at 3:51 PM, Gábor Csárdi <address@hidden> wrote:
Dear Anupam,

there are several mistakes in your code. Here is a working version, I
haven't tested it much, sorry, no time right now.

library(igraph)

path <- "/tmp/test/"

## Some test data
dir.create(path)
for (i in 1:10) {
 g <- erdos.renyi.game(10, 1/10)
 write.graph(g, file=paste(sep="", "/tmp/test/graph", i, ".ncol"))
}

####

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(path, files[i], j, sep="")
   write.graph(j, file=gr_name, format="ncol")
 }
}

Please read it over, compare it to yours, and tell us if something is not clear.

Best,
Gabor


On Fri, Oct 1, 2010 at 9:53 AM, anupam sinha <address@hidden> wrote:
>
>
>
>>
>>
>> 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
>>
>>
>>
>>
>>
>
>
> --
> Graduate Student,
> Center For DNA Fingerprinting And Diagnostics,
> 4-1-714 to 725/2, Tuljaguda complex
> Mozamzahi Road, Nampally,
> Hyderabad-500001
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



--
Gabor Csardi <address@hidden>     UNIL DGM

_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help



--
Graduate Student,
Laboratory of Computational Biology,
Center For DNA Fingerprinting And Diagnostics,
4-1-714 to 725/2, Tuljaguda complex
Mozamzahi Road, Nampally,
Hyderabad-500001

reply via email to

[Prev in Thread] Current Thread [Next in Thread]