RoheLab / aPPR

Approximate Personalized Page Rank
https://rohelab.github.io/aPPR/
Other
16 stars 3 forks source link

Add method for snowball sampling #13

Open alexpghayes opened 4 years ago

alexpghayes commented 4 years ago

Basically BFS, something along the lines of

sample_snowball <- function(
  users, hops,
  direction = c(
    "following",
    "followed-by",
    "both"
  )) {

  if (hops < 0)
    stop("`hops` must be greater than zero.")

  direction <- rlang::arg_match(direction)

  for (user in users)
    if (!users_in_cache(user))
      add_users_to_cache(user)

  # TODO: respect direction in the future

  friends <- cache_get_friends(users)

  sample_snowball(friends, hops - 1)
}