[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] how to properly generate a barabasi graph in Python without mul
From: |
Arun |
Subject: |
[igraph] how to properly generate a barabasi graph in Python without multi-edges |
Date: |
Wed, 23 Dec 2009 00:19:40 -0600 |
Hi all,
I'm using python-igraph and am confused as to how to generate an
undirected, scale-free barabasi graph of 1000 nodes WITHOUT
multi-edges and self-loops. When I use the built-in method, it always
generates graphs with multi-edges. If using simplify(), this will
possibly result in a graph that doesn't follow the power law.
In a previous question on the mailing list from more than a year ago,
it was suggested that one could do this in R:
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)
}
Not that familiar with R. What is the easiest way to generate an
undirected, scale-free graph of 1000 nodes WITHOUT
multi-edges/self-loops in Python?
Thank you very much.
- [igraph] how to properly generate a barabasi graph in Python without multi-edges,
Arun <=