igraph-help
[Top][All Lists]
Advanced

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

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


From: Salvatore Loguercio
Subject: Re: [igraph] Degree-preserving rewiring of a large graph
Date: Wed, 02 Apr 2014 11:04:03 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

Thanks much Tamas, this is an useful workaround. Regarding the NA values, I can file a bug report somewhere for igraph.
-sal

On 4/1/2014 11:36 AM, Tamás Nepusz wrote:
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.

------------------------------------------------------
From: Salvatore Loguercio address@hidden
Reply: Help for igraph users address@hidden
Date: 1 April 2014 at 19:45:01
To: address@hidden address@hidden
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
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help




reply via email to

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