Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 143 additions & 11 deletions R/games.R
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,15 @@ degseq <- function(..., deterministic = FALSE) {
#' g2 <- sample_growing(500, citation = TRUE)
#'
#' @cdocs igraph_growing_random_game
sample_growing <- growing_random_game_impl
sample_growing <- function(n, m = 1, ..., directed = TRUE, citation = FALSE) {
growing_random_game_impl(
n = n,
m = m,
...,
directed = directed,
citation = citation
)
}

#' @rdname sample_growing
#' @param ... Passed to `sample_growing()`.
Expand Down Expand Up @@ -2495,7 +2503,21 @@ sample_bipartite_gnp <- function(
#' @family games
#' @export
#' @cdocs igraph_sbm_game
sample_sbm <- sbm_game_impl
sample_sbm <- function(
n,
pref.matrix,
block.sizes,
directed = FALSE,
loops = FALSE
) {
sbm_game_impl(
n = n,
pref.matrix = pref.matrix,
block.sizes = block.sizes,
directed = directed,
loops = loops
)
}

#' @rdname sample_sbm
#' @param ... Passed to `sample_sbm()`.
Expand Down Expand Up @@ -2624,7 +2646,12 @@ hierarchical_sbm <- function(...) {
#' @family games
#' @export
#' @cdocs igraph_dot_product_game
sample_dot_product <- dot_product_game_impl
sample_dot_product <- function(vecs, directed = FALSE) {
dot_product_game_impl(
vecs = vecs,
directed = directed
)
}

#' @rdname sample_dot_product
#' @param ... Passed to `sample_dot_product()`.
Expand Down Expand Up @@ -2656,7 +2683,14 @@ dot_product <- function(...) constructor_spec(sample_dot_product, ...)
#' @family games
#' @export
#' @cdocs igraph_simple_interconnected_islands_game
sample_islands <- simple_interconnected_islands_game_impl
sample_islands <- function(islands.n, islands.size, islands.pin, n.inter) {
simple_interconnected_islands_game_impl(
islands.n = islands.n,
islands.size = islands.size,
islands.pin = islands.pin,
n.inter = n.inter
)
}


#' Create a random regular graph
Expand Down Expand Up @@ -2695,7 +2729,19 @@ sample_islands <- simple_interconnected_islands_game_impl
#' @family games
#' @export
#' @cdocs igraph_k_regular_game
sample_k_regular <- k_regular_game_impl
sample_k_regular <- function(
no.of.nodes,
k,
directed = FALSE,
multiple = FALSE
) {
k_regular_game_impl(
no.of.nodes = no.of.nodes,
k = k,
directed = directed,
multiple = multiple
)
}


#' Random graph with given expected degrees
Expand Down Expand Up @@ -2844,7 +2890,21 @@ sample_k_regular <- k_regular_game_impl
#' ))
#' @export
#' @cdocs igraph_chung_lu_game
sample_chung_lu <- chung_lu_game_impl
sample_chung_lu <- function(
out.weights,
in.weights = NULL,
...,
loops = TRUE,
variant = c("original", "maxent", "nr")
) {
chung_lu_game_impl(
out.weights = out.weights,
in.weights = in.weights,
...,
loops = loops,
variant = variant
)
}

#' @rdname sample_chung_lu
#' @export
Expand Down Expand Up @@ -2926,7 +2986,21 @@ chung_lu <- function(
#' degree_distribution(g)
#' plot(degree_distribution(g, cumulative = TRUE), log = "xy")
#' @cdocs igraph_static_fitness_game
sample_fitness <- static_fitness_game_impl
sample_fitness <- function(
no.of.edges,
fitness.out,
fitness.in = NULL,
loops = FALSE,
multiple = FALSE
) {
static_fitness_game_impl(
no.of.edges = no.of.edges,
fitness.out = fitness.out,
fitness.in = fitness.in,
loops = loops,
multiple = multiple
)
}


#' Scale-free random graphs, from vertex fitness scores
Expand Down Expand Up @@ -2993,7 +3067,25 @@ sample_fitness <- static_fitness_game_impl
#' g <- sample_fitness_pl(10000, 30000, 2.2, 2.3)
#' plot(degree_distribution(g, cumulative = TRUE, mode = "out"), log = "xy")
#' @cdocs igraph_static_power_law_game
sample_fitness_pl <- static_power_law_game_impl
sample_fitness_pl <- function(
no.of.nodes,
no.of.edges,
exponent.out,
exponent.in = -1,
loops = FALSE,
multiple = FALSE,
finite.size.correction = TRUE
) {
static_power_law_game_impl(
no.of.nodes = no.of.nodes,
no.of.edges = no.of.edges,
exponent.out = exponent.out,
exponent.in = exponent.in,
loops = loops,
multiple = multiple,
finite.size.correction = finite.size.correction
)
}


#' Forest Fire Network Model
Expand Down Expand Up @@ -3056,7 +3148,21 @@ sample_fitness_pl <- static_power_law_game_impl
#' plot(seq(along.with = dd1) - 1, dd1, log = "xy")
#' points(seq(along.with = dd2) - 1, dd2, col = 2, pch = 2)
#' @cdocs igraph_forest_fire_game
sample_forestfire <- forest_fire_game_impl
sample_forestfire <- function(
nodes,
fw.prob,
bw.factor = 1,
ambs = 1,
directed = TRUE
) {
forest_fire_game_impl(
nodes = nodes,
fw.prob = fw.prob,
bw.factor = bw.factor,
ambs = ambs,
directed = directed
)
}


#' Generate a new random graph from a given graph by randomly
Expand Down Expand Up @@ -3096,7 +3202,19 @@ sample_forestfire <- forest_fire_game_impl
#' g
#' g2
#' @cdocs igraph_correlated_game
sample_correlated_gnp <- correlated_game_impl
sample_correlated_gnp <- function(
old.graph,
corr,
p = edge_density(old.graph),
permutation = NULL
) {
correlated_game_impl(
old.graph = old.graph,
corr = corr,
p = p,
permutation = permutation
)
}


#' Sample a pair of correlated \eqn{G(n,p)} random graphs
Expand Down Expand Up @@ -3134,4 +3252,18 @@ sample_correlated_gnp <- correlated_game_impl
#' gg
#' cor(as.vector(gg[[1]][]), as.vector(gg[[2]][]))
#' @cdocs igraph_correlated_pair_game
sample_correlated_gnp_pair <- correlated_pair_game_impl
sample_correlated_gnp_pair <- function(
n,
corr,
p,
directed = FALSE,
permutation = NULL
) {
correlated_pair_game_impl(
n = n,
corr = corr,
p = p,
directed = directed,
permutation = permutation
)
}