igraph-help
[Top][All Lists]

## Re: [igraph] Degree-preserving rewiring of a large graph

 From: Tamás Nepusz Subject: Re: [igraph] Degree-preserving rewiring of a large graph Date: Tue, 1 Apr 2014 20:36:25 +0200

```Not sure why the NA values appear in your graphs -- we would need a
reproducible example to be able to investigate this. However, one trick that
you could use is to “save” your original weights vector in a variable, and then
for every generated graph, shuffle the weights vector and assign it to the
edges of the generated graph. E.g.:

weights <- E(g)\$weight
g2 <- degree.sequence.game(degree(g), method=“vl”)
E(g2)\$weight <- scramble(weights)

where scramble() is a function that takes a vector and shuffles it; something
like:

scramble <- function(x, k=3L) {
x.s <- seq_along(x)
y.s <- sample(x.s)
x[unlist(split(x.s[y.s], (y.s-1) %/% k), use.names = FALSE)]
}

(scramble function copied shamelessly from here:
http://stackoverflow.com/a/17640731/156771)

--
T.

------------------------------------------------------
Date: 1 April 2014 at 19:45:01
Subject:  Re: [igraph] Degree-preserving rewiring of a large graph

> Okay, to answer my own question I went on and used niter=10000 (my graph
> is 14736 nodes and 153834 edges, weighted, self loops and double edges
> removed) - I generated 1000 simulated graphs this way. Only, the rewired
> graphs have some NA in the adjacency matrix - also reported in
> http://stackoverflow.com/questions/21179746/how-do-you-rewire-a-weighted-network-using-igraph-in-r.
>
> Is this expected somehow? I used "simple" option in rewire.
>
> Best,
> Sal
>
> _______________________________________________
> igraph-help mailing list