[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [igraph] about rewire fuction

**From**: |
Qunawei Zhang |

**Subject**: |
Re: [igraph] about rewire fuction |

**Date**: |
Fri, 06 Sep 2013 15:01:21 -0400 |

**User-agent**: |
Microsoft-MacOutlook/14.3.6.130613 |

That makes sense. Many thanks.
Best
Quanwei
On 9/6/13 2:24 PM, "Tamás Nepusz" <address@hidden> wrote:
>*> In the manual it said "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."*
>*> How do you determine which node is "a" given an edge? "a" is always the*
>*>node with smaller ID than "b"?*
>*Take a look at the source code here:*
>
>*https://github.com/igraph/igraph/blob/master/src/structural_properties.c#L*
>*1509*
>
>*Basically, we generate two random numbers between 0 (inclusive) and m-1*
>*(inclusive), where m is the number of edges. Then we take the edges with*
>*the generated IDs and extract their endpoints into (a,b) and (c,d). In*
>*case of directed graphs, there is nothing else to do -- a and c will be*
>*the sources of the two edges while b and d will be the targets. In case*
>*of undirected graphs, the call to igraph_edge returns (a,b) and (c,d)*
>*such that a<b and c<d, so we swap c with d with probability 0.5. This way*
>*we perform one of two possible rewirings with equal chance:*
>
>*1. (a,b) and (c,d) becomes (a,d) and (c,b)*
>*2. (a,b) and (d,c) becomes (a,c) and (d,b)*
>
>*> Do you agree? And would you please tell me where can I find the source*
>*>code of rewire function? I want to look at the details.*
>*It starts here:*
>
>*https://github.com/igraph/igraph/blob/master/src/structural_properties.c#L*
>*1464*
>
>*Best,*
>*Tamas*
>*_______________________________________________*
>*igraph-help mailing list*
>*address@hidden*
>*https://lists.nongnu.org/mailman/listinfo/igraph-help*