R/umbrella_module_apply_random_seed.R

Defines functions ApplyRandomSeed

Documented in ApplyRandomSeed

#!/usr/bin/env Rscript

##########
# Notice #
##########

# Umbrella: A Biased Generic Random Walk Algorithm for Community Detection
# Copyright (C) 2020 William Willis Whinn

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#############
# Functions #
#############

ApplyRandomSeed <- function() {
  if (exists('.Random.seed')) {
    # Delete the current seed (if exists).
    rm(.Random.seed, envir = globalenv())
  }

  # Choose a random number and use it as a random seed.
  random_seed <- sample(1:1e6, 1, replace = FALSE)
  set.seed(random_seed)

  # Print chosen seed
  print(paste('NOTE: Random seed', random_seed, "has been applied."))
}

# End of File.
ultraviolet-1986/umbrella documentation built on July 20, 2020, 9:02 p.m.