[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] preserving multiple graphs
From: |
Gabor Csardi |
Subject: |
Re: [igraph] preserving multiple graphs |
Date: |
Mon, 11 Feb 2008 09:40:24 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Uri,
On Sun, Feb 10, 2008 at 07:45:19PM -0500, Uri Shwed wrote:
> Hi Gabor and all,
> I'm trying to analyze the unfolding of a network over time, using
> cohesive blocks. Since towards the end of my time frame the network
> becomes quite huge, I thought it would be useful to first store all
> the graphs into a list, and then cohesive.blocks the periods
> separately. This has taught me that lists don't store graphs - is
> that true? How do one stores graphs then? I wouldn't mind even saving
> them as separate files, but I do need a way to give those files
> serial names automatically.
hmmm, lists are perfect for storing graphs, in fact, they are perfect
for storing anything. E.g.
l <- list( ba.game(1000, m=3, dir=FALSE),
erdos.renyi.game(1000, 3000, type="gnm") )
sapply(l, transitivity)
works fine.
Before checking your code. There is a bug in the 0.4.5 release in the
cohesive.blocks function, sometimes the cohesive blocks are not
calculated correctly. We will release a corrected version, igraph 0.5
soon. If you can't wait, see this message for preliminary packages:
http://lists.gnu.org/archive/html/igraph-help/2008-02/msg00011.html
> I hope I'm making some sense...I'm just doing my first baby steps in
> R. Here's the code I have:
>
>
> ##this function takes data of 3 columns - sender(citing), receiver
> (cited) and year(citey), and uses a moving window to build many
> networks, and store them by the first year in the window .
>
> window.matgrf<-function(data, start=1950, end=1990, lag=8) {
> t<-start
> lag<-lag
> end<-end
> last<-end-lag
> years<-start:end
> lis<<-list(year=NA,mtrx=NA,grf=NA)
Do not use <<- here, it is not needed. Actually <<- is very rarely
needed and it will almost always a source of great confusion, whenever
you use it.
> lstname<<-list(year=NA,mtrx=NA,grf=NA,blks=NA,blkgrf=NA) //This is
> for future use with faster machines - maybe I could get the blocks on
> this run.
> for (t in start:last) {
> mtx<-matrix(c(data$citing[data$citey>=t & data$citey
> <=t+lag], data$cited [data$citey >=t & data$citey
> <=t+lag]), ncol=2)
> print(t)
> grfy<-graph.edgelist(mtx)
> print(is.igraph(grfy))
> lis<-list(year=t, matrx=mtx,grf=grfy)
> lstname[t]<<-list(lis)
> t<-t+1
>
> }
> lstname
> }
> ##so to build a list called Set:
>
> Set<-window.matgrf(FullData, end=1994)
> ## and then to get the cohesive blocks for 1977 - 1985:
> cohesive.blocks(Set[[1975]][2])
>
It would be easier if you sent a reproducible example, with the
code only i would need to figure out how your input data looks like,
made up some toy input data, etc. From the code it seems to me that
you don't have a list of graphs here, but a list of lists, and the
third ('grf') elements of the "small" lists are the graphs.
If this is true then you need something like
cohesive.blocks(Set[[1975]]$grf)
or if you're sure that the graph is always the third element, then
cohesive.blocks(Set[[1975]][[3]])
Gabor
ps. it is ok if you're not on the list, but then please note thar
your emails will be delayed, as a i need to acknowledge them "by hand".
--
Csardi Gabor <address@hidden> UNIL DGM