R/RcppExports.R

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' random sample based on http://goo.gl/ZzIHGM
#'
#' Samples without replacement of size size from N points
#'
#' @param N number of points in graph
#' @param size sample size
#' @param prob set to equal
#'
#' @return index of points
random_sample <- function(N, size, prob = as.numeric( c())) {
    .Call('graphResiduals_random_sample', PACKAGE = 'graphResiduals', N, size, prob)
}

#' Given a distance matrix, and a index, calculates
#' residuals (erods, waxman) as well as average distance which
#' can be used to get barabasi residuals
#'
#' @param dist matrix of distances -ve means edge
#' @param index of selected rows
#' @param q waxman parameter
#' @param s waxman parameter
#'
#' @return matrix of distances and residuals
get_residuals <- function(dist, sample_size, q, s) {
    .Call('graphResiduals_get_residuals', PACKAGE = 'graphResiduals', dist, sample_size, q, s)
}

#' get residuals for multiple sampled subgraphs
#'
#' Given a pairwise distance matrix, performs n_samples of size
#' sample_size sampled subgraphs, for each it returns the
#' edge fraction, the mean waxman prob, the mean node age,
#' the mean distance
#'
#' @param dist pairwise distance matrix
#' @param sample_size number of nodes in sampled subgraph
#' @param n_samples the number of sampled subgraphs
#' @param q waxman parameter to calcute waxman prob
#' @param s waxman parameter to calcute waxman prob
#'
#' @return data frame with the given information
get_residuals_multi <- function(dist, sample_size, n_samples, q, s) {
    .Call('graphResiduals_get_residuals_multi', PACKAGE = 'graphResiduals', dist, sample_size, n_samples, q, s)
}

#' calculate Euclidean distance between x and y
#'
#' @param x two dim point
#' @param y two dim point
#' @return distance
get_dist <- function(x, y) {
    .Call('graphResiduals_get_dist', PACKAGE = 'graphResiduals', x, y)
}

#' create distance matrix for N nodes
#'
#' sim points on unit square then calculates the
#' pairwise distances
#'
#' @param N number of points
#'
#' @return distance matrix
sim_dist <- function(N) {
    .Call('graphResiduals_sim_dist', PACKAGE = 'graphResiduals', N)
}

#' simulate an erdos network with N nodes and p prob of an edge
#'
#' structure is a distance matrix with negative numbers for an edge
#' and positive distances for no edge
#'
#' @param N number of nodes
#' @param p probability of an edge
#'
#' @return pairwise distance matrix
sim_erdos <- function(N, p) {
    .Call('graphResiduals_sim_erdos', PACKAGE = 'graphResiduals', N, p)
}

#' returns pij from distance and parameters q and s
#' @param dist distance between two nodes
#' @param q waxman parameter
#' @param s waxman parameter
#'
#' @return pij
get_pij <- function(dist, q, s) {
    .Call('graphResiduals_get_pij', PACKAGE = 'graphResiduals', dist, q, s)
}

#' simulate a waxman graph with N nodes and parameters q and s
#'
#' distance based edge probability
#'
#' @param N number of nodes
#' @param q thinning parameter
#' @param s relates distance to prob
#'
#' @return pairwise distance matrix - postive distances is an edge, negative is no edge
sim_waxman <- function(N, q, s) {
    .Call('graphResiduals_sim_waxman', PACKAGE = 'graphResiduals', N, q, s)
}

#' simulate a barabasi graph for N nodes and m0 primary nodes
#'
#' cheat by using the igraph barabasi code to get the edges and
#' then get distances
#'
#' @param N number of nodes
#' @param edge edge list from igraphs barabasi game
#'
#' @return pairwise distance matrix positive is an edge, negative is no edge
#'
sim_barabasi_cpp <- function(N, edge) {
    .Call('graphResiduals_sim_barabasi_cpp', PACKAGE = 'graphResiduals', N, edge)
}
jonotuke/graphResiduals documentation built on May 19, 2019, 8:37 p.m.