[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] rewire() and self loops
From: |
Gábor Csárdi |
Subject: |
Re: [igraph] rewire() and self loops |
Date: |
Thu, 11 Oct 2012 15:43:22 -0400 |
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 <address@hidden> 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
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
--
Gabor Csardi <address@hidden> MTA KFKI RMKI