Hi,
On Mon, Feb 1, 2010 at 8:58 PM, Arthur Kaiser<address@hidden> wrote:
Hallo,
do R-implementations of games exist?
no, at least not within the package. There might be some code
available here and there, e.g. on this mailing list.
I especially need a R-implementation of aging.prefatt.game.
Here is an example of a simple barabasi.game implementation:
my.ba.game<-function(n, directed){
graph<-graph.empty(directed)
graph<-add.vertices(graph, 1) #add first vertex
for(i in 1:n){
# snapshot
# if(i==x) {write graph}
# and the rest
graph<-add.vertices(graph, 1) #add a vertex
startvertices<-graph[4][[1]] #in degree
These are indeed the "incoming ends" of the edges, but I would not do
this. This is a violation of the API. Why don't you simply use an edge
list matrix in this loop (probably with pre-allocated size to save
time)? You are not really using anything igraph specific, anyway.
maxj<-length(startvertices)
j<-sample(1:maxj, 1)
vj<-startvertices[j] #to
if(maxj==0){graph<-add.edges(graph, c(i,0))
}else{graph<-add.edges(graph, c(i, vj))}
graph<-simplify(graph)
}
return(graph)
}
Are you wondering why I ask for this? I need snapshots of the graph during
the generation process. I also want to combine games e.g. ba with a d-dim
latice or a randoom game without writing it in c and compile. Can someone
help me please?
Tamás already told you about the snapshots. I'm not sure what you mean
by 'combine', but you could just create the lattice separately and
create the union of the two graphs. See e.g. graph.union.
In general, we don't want to rewrite everything in R, just to have
another implementation, so I'm afraid that you'll need to do this for
yourself. Note that the R implementations of these functions will
typically contain 'for' loops and they will be much slower than the C
versions.
Best Regards,
Gabor
Thanks in advance.
Arthur Kaiser
University of Applied Sciences Brandenburg
Faculty of Computer Science and Media
_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help