[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] Random Walk Sample
From: |
Thomas |
Subject: |
[igraph] Random Walk Sample |
Date: |
Thu, 24 Oct 2013 14:10:12 +0100 |
I'm creating a sample of nodes according to the random walk procedure
described in Section 3.3.3 of:
http://www.stat.cmu.edu/~fienberg/Stat36-835/Leskovec-sampling-kdd06.pdf
The following R code samples no less than 300 nodes, although it might
sample the same node twice but it runs really slowly. Does anyone know
why it might be going so slow? Is there any better way to do this?
Thank you,
Thomas
#Random Walk Sample of nodes from network g
#Read graph g in as UNDIRECTED
A <- sample(1:length(degree(g)), 1)
oput <- c()
oput <- c(oput, A)
flag <- FALSE
count <- 1
while(count <= 300)
{
node1 <- A
while(flag==FALSE)
{
node2 <- sample(neighbors(g,node1),1)
oput <- c(oput, node2)
count <- count + 1
node1 <- node2
if(rbinom(1,1,0.15)==1){flag=TRUE}
}#end of while flag loop
}#end of while count loop
This message and any attachment are intended solely for the addressee and may
contain confidential information. If you have received this message in error,
please send it back to me, and immediately delete it. Please do not use, copy
or disclose the information contained in this message or in any attachment.
Any views or opinions expressed by the author of this email do not necessarily
reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system, you
are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
- [igraph] Random Walk Sample,
Thomas <=