igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] barabasi.game without multiple edges but with loops ?


From: Gabor Csardi
Subject: Re: [igraph] barabasi.game without multiple edges but with loops ?
Date: Tue, 20 May 2008 15:04:05 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Amelie,

this is not possible with the current implementation of 'barabasi.game',
but you can easily write a version that does what you want, using 
possibly 'igraph.sample'. (But for small networks, the R builtin 'sample' can
be good enough, too, especially because igraph.sample seems to be buggy a bit.)

It would be something like this:


barabasi.game2 <- function(n, m) {

  edges <- numeric()
  for (i in 2:n) {
    no.neis <- min(i-1, m)
    neis <- rbind( i, sample(1, i, no.neis) )
    edges <- c(edges, neis)
  }

  graph(edges-1)
}

> g <- barabasi.game2(10000, m=3)
> summary(g)
Vertices: 10000 
Edges: 29994 
Directed: TRUE 
No graph attributes.
No vertex attributes.
No edge attributes.
> any(is.multiple(g))
[1] FALSE
> any(is.loop(g))
[1] TRUE

Gabor

ps. please consider joining the mailing list, otherwise 1) you might miss
some answers to your questions and 2) your messages will be delayed.

On Tue, May 20, 2008 at 01:54:35PM +0200, Amelie Veron wrote:
> Dear list,
> 
> Does anybody know if it is possible to generate a network with the
> barabasi.game function that wouldn't have any multiple edges, but
> would include self interactions ?
> 
> simplify(graph) is not an option as I would like to make sure there
> are a given number of edges in the generated graphs.
> 
> here is the command I use (where len is the number of vertices and vec
> a vector of how many edges to add for each new vertex).
> 
> net = barabasi.game(len,out.seq=vec,directed=FALSE,out.pref=TRUE)
> 
> Just in case somebody has a better idea overall, here is what I am trying to 
> do:
>  - I have a few very small networks (from 32 to 74 vertices)
>  - I would like to  see whether they could be scale-free-like or
> totally not scale-free.
>  - For that, I want to generate random scale-free-like networks with
> the same number of vertices and edges as the real-life networks and
> compare the real networks with the generated ones.
> 
> So the generated networks have to be generated with a model that can,
> for bigger networks, generate scale-free networks. They have to have a
> given number of edges and a given number of vertices. Lastly, they
> have to include self-interactions but no multiple edges.
> 
> Thanks a lot for your time !
> 
> Amelie
> 
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help

-- 
Csardi Gabor <address@hidden>    UNIL DGM




reply via email to

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