Hi Dov, I have recently fixed this in the development branch. If you wanna give it a go and don't mind compiling it yourself, check out the nightly build tomorrow:
http://code.google.com/p/igraph/downloads/list Revision 3006 of the 0.7-main tree should include all the changes -- this will be uploaded around 6am GMT tomorrow. Best, -- T. On Thursday, 11 October 2012 at 21:43, Gábor Csárdi wrote: > Hi Dov, > > I think this is simply a bug. He have this in the C code for rewire: > > if (!igraph_vector_search(neis[0], 0, d, NULL) && > !igraph_vector_search(neis[1], 0, b, NULL) && > b!=c && a!=d && a!=b && c!=d) { > do the rewiring here > } > > So, yes, if a=b or a=d, or b=c or c=d, the rewiring is not performed, > I am not sure why. I have submitted a bug report for this: > https://bugs.launchpad.net/igraph/+bug/1065681 > > Thanks, Best, > Gabor > > > On Thu, Oct 11, 2012 at 3:29 PM, Dov Pechenick <[email protected] > (mailto:[email protected])> wrote: > > Hello, > > > > 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.) > > > > Thanks! > > Dov > > > > _______________________________________________ > > igraph-help mailing list > > [email protected] (mailto:[email protected]) > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > -- > Gabor Csardi <[email protected] (mailto:[email protected])> MTA KFKI RMKI > > _______________________________________________ > igraph-help mailing list > [email protected] (mailto:[email protected]) > https://lists.nongnu.org/mailman/listinfo/igraph-help _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
