igraph-help
[Top][All Lists]

## Re: [igraph] R-implementations of games

 From: Arthur Kaiser Subject: Re: [igraph] R-implementations of games Date: Wed, 03 Feb 2010 16:55:44 +0100 User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1

```Hi,
@Tamas. Thanks. I want to do it right this way.

@Gabor

```
How can I get and use an edge list matrix? Can you give me a code example, please?
```
I'm actualy thinking about an aging.prefatt.game with a random part:

P[i] ~ (c k[i]^alpha) (d l[i]^beta) (e r[i]^gamma)

The combine which I´m referring is shown in this example:

my.example.game<-function(n, directed=TRUE){

graph<-graph.empty(directed)

for(i in 1:n){

# and the rest

#regular latice

#some flavour of er

#some flavour of ba
startvertices<-graph[4][[1]] #incoming ends vector
maxj<-length(startvertices)

j<-sample(1:maxj, 1)
vj<-startvertices[j] #to

graph<-simplify(graph)
}
return(graph)
}

```
I don´t think that this would be an usefull combination. I like to try out some -more or less strange- ideas, especially quick and easy ones. You are right. R implementations are slower, but performance is not the problem. It's ok for me to wait some seconds longer. If I create the union of two graphs (e.g. ba+lattice) the result should have different properties than the graphs which I generated within my example (without random part). What do you think about this?
```
Best Regards,
Arthur

Am 02.02.2010 13:29, schrieb Gábor Csárdi:
```
```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)

for(i in 1:n){
# snapshot
# if(i==x) {write graph}

# and the rest

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

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
```
```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
http://lists.nongnu.org/mailman/listinfo/igraph-help

```
```

```
```

```