igraph-help
[Top][All Lists]
Advanced

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

[igraph] Rewire probabilities question


From: Mark Orr
Subject: [igraph] Rewire probabilities question
Date: Fri, 19 May 2017 09:24:25 -0400

Hi All, 
I’m using rewire(g,each_edge(p=x)).  One of my needs is to identify which of 
the edges in the rewired graph are rewires from the original graph for which 
I’ve written a piece of code below. (SEE SIMPLE EXAMPLE BELOW).    I have two 
questions for which I would be very appreciative of an answer from the group.  
I’m not well versed in C code, so the git repository doesn’t really help me in 
figuring this out. 

Q1:  Does the code below identify properly the new edges in the rewired graph 
in comparison to the original?  

Q2:  Why is it that, with a rewire of approx p=.30, I get approx 50% new edges 
(given the way I’ve defined new below).

Any help very much appreciated.

Thanks, 
Mark


#BEGIN
rm(list=ls())

#MAKE ORIGINAL AND REWIRED GRAPH--tested with ring then watts...
#g.1 <- graph.ring(10000)
g.1 <- watts.strogatz.game(dim=1,size=10000,nei=2,p=0)
g.2 <- rewire(g.1,each_edge(prob=.29))

#COMBINE EDGE LISTS INTO DATA FRAME FOR COMPARISON
g.1.edgeframe <- data.frame(get.edgelist(g.1))
g.2.edgeframe <- data.frame(get.edgelist(g.2))
g.comb <- cbind(g.1.edgeframe,g.2.edgeframe)
names(g.comb) <- c("g1.a","g1.b","g2.a","g2.b")

#ASSESS REWIRED EDGES 
g.comb$new <- 1
g.comb$new[g.comb$g1.a==g.comb$g2.a & g.comb$g1.b==g.comb$g2.b] <- 0

#CALCULATE PROPORTION NEW
print(mean(g.comb$new))

#EOF
-------------------------------------------------------
Mark Orr
Research Associate Professor
Social and Decision Analytics Laboratory
Biocomplexity Institute of Virginia Tech
900 North Glebe Rd.
Arlington, VA 22203
p: 571-858-3116
f: 571-858-3015
address@hidden







reply via email to

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