[Top][All Lists]

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

[igraph] rewire() and self loops

From: Dov Pechenick
Subject: [igraph] rewire() and self loops
Date: Thu, 11 Oct 2012 15:29:16 -0400


I'm using igraph in R, and I'm trying to randomize the edges of directed graphs while preserving in- and out-degree distributions.  Since my graphs are directed, I don't use degree.sequence.game().  Instead, I've been using rewire().  This function correctly preserves the degree distribution, however as far as I can tell it completely ignores self loop edges during the rewiring process.  That is to say, every single self loop in my original network is also preserved in all my rewired networks.  I did not expect this based on the documentation:

"simple rewiring algorithm which chooses two arbitrary edges in each step (namely (a,b) and (c,d)) and substitutes them with (a,d) and (c,b) if they don't yet exist"

While true that self loops aren't explicitly mentioned, the most general form of the algorithm allows a==b and c==d.  Thus, this algorithm should allow for the generation and destruction of self-loops.  For example, a->a and b->b can be replaced with a->b and b->a if they don't yet exist.  The reverse should also be a valid swap.  I tested this on the following networks, just to be sure:

a <- graph(c(0,0,1,1,2,2,3,3)) # 4 nodes, only self loops
b <- graph(c(0,1,1,0,2,3,3,2,0,2,2,0,0,3,3,0,1,2,2,1,1,3,3,1)) # 4 node complete graph, no self loops

Rewiring using rewire() does nothing to the above graphs.  For a, self loops are never destroyed, and for b, they are never created.  If I am missing something, please let me know.  Otherwise, is there a way to rewire directed graphs that both preserves degree distribution and allows for the generation and destruction of self-loops?  (Ideally it would be the same function, with an option to allow self-loops.)


reply via email to

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