R/sim_networks_fns.R

#' code to get barabasi for given number of nodes
#' and number of edges to add each time
#'
#' @param N number of nodes
#' @param m number of edges to add each time
#'
#' @return pairwise distance matrix negative dist is an edge
sim_barabasi <- function(N, m)
{
  g <- igraph::barabasi.game(n = N, m = m, directed = FALSE)
  bara <- sim_barabasi_cpp(N, igraph::as_edgelist(g))
  return(bara)
}
#' function to duplicate rows in data frame
#'
#' @param df data frame
#' @param reps number to replicate each row
#'
#' @return data frame
duplicate_rows <- function(df, reps=100)
{
  index <- rep(1:nrow(df), each=reps)
  df <- df[index,]
  df$ID <- 1:nrow(df)
  return(df)
}
jonotuke/graphResiduals documentation built on May 19, 2019, 8:37 p.m.