generate_category_graphs: Generate a Set of Graphs with Similar Community Structures...

View source: R/generate_category_graphs.R

generate_category_graphsR Documentation

Generate a Set of Graphs with Similar Community Structures for a Category

Description

This function generates a list of adjacency matrices representing brain networks belonging to the same category (e.g., Control group). Every graph has the same community structure, and each edge is an independent Bernoulli variable with the within- or between-community probability. By default all graphs share the same probabilities; optionally, the probabilities of each graph can be shifted at random (see intra_prob_variation and inter_prob_variation).

Usage

generate_category_graphs(
  n_graphs = 10,
  n_nodes = 100,
  n_communities = 4,
  community_sizes = NULL,
  base_intra_prob = 0.8,
  base_inter_prob = 0.2,
  intra_prob_variation = 0,
  inter_prob_variation = 0,
  seed = NULL
)

Arguments

n_graphs

An integer specifying the number of graphs to generate. Default is 10.

n_nodes

An integer specifying the total number of nodes (brain regions). Default is 100.

n_communities

An integer specifying the number of communities. Default is 4.

community_sizes

An integer vector specifying the sizes of each community. If NULL, communities are of equal size. Default is NULL.

base_intra_prob

A numeric value between 0 and 1, or a numeric vector of length n_communities, specifying the base probability of an edge existing between nodes within the same community. If a vector, each element sets the base probability for the corresponding community. Default is 0.8.

base_inter_prob

A numeric value between 0 and 1 specifying the base probability of an edge existing between nodes from different communities. Default is 0.2.

intra_prob_variation

A numeric value v \ge 0. If positive, the within-community probability of each community is shifted, in every graph, by an amount drawn uniformly from [-v, v], independently for each community and each graph (and truncated to [0, 1]). Default is 0: no variation, all graphs share the same probabilities.

inter_prob_variation

A numeric value v \ge 0. If positive, the between-community probability of every graph is shifted by an amount drawn uniformly from [-v, v], independently for each graph. Default is 0.

seed

An optional integer for setting the random seed to ensure reproducibility. Default is NULL.

Value

A list of symmetric binary adjacency matrices with no self-loops, representing brain networks with similar community structures.

Examples

# Generate a set of 5 graphs for the Control category
control_graphs <- generate_category_graphs(n_graphs = 5, n_nodes = 100, n_communities = 4,
                                           base_intra_prob = 0.8, base_inter_prob = 0.2)

BrainNetTest documentation built on Dec. 3, 2026, 5:08 p.m.