Rewiring and loop edges
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
igraph |
Fix Released
|
Medium
|
Tamás Nepusz |
Bug Description
Hi Dov,
I think this is simply a bug. He have this in the C code for rewire:
if (!igraph_
!igraph_
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:
****
Thanks, Best,
Gabor
On Thu, Oct 11, 2012 at 3:29 PM, Dov Pechenick <*> 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.
> 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(
> b <- graph(c(
> 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
Changed in igraph: | |
milestone: | none → 0.6.1 |
Changed in igraph: | |
status: | Fix Committed → Fix Released |
This can only go in 0.7 because adding a "loops" option to 0.6.1 would break API compatibility. Alternatively, we could silently switch to allowing the creation of loops in igraph_rewire in 0.6.2, but I guess most of our users who rely on the (undocumented) feature of igraph_rewire not allowing loops would not be happy with this -- including me ;)