generate_graph: Generate a random graph

Description Usage Arguments Value Examples

View source: R/generate_graph.R

Description

Function generate_graph generates a random network using igraph graph generators. Several models are available, and

Usage

1
2
3
4
5
6
7
8
generate_graph(
    fun_gen,
    param_gen,
    class_label = NULL,
    class_attr = .default_graph_param(),
    fun_curate = .connect_undirected_graph,
    seed = NULL
)

Arguments

fun_gen

function to generate the graphs. Typically from igraph, like barabasi.game, watts.strogatz.game, erdos.renyi.game, make_lattice, etc.

param_gen

list with parameters to pass to fun_gen

class_label

character vector with length equal to the number of nodes in the graph to generate. If left to NULL, the default classes are c("source", "filler", "end") with proportions of c(0.05, 0.45, 0.5).

class_attr

data.frame with vertex classes as rownames and a column for each vertex attribute. The name of the column will be used as the attribute name.

fun_curate

function to apply to the graph before returning it. Can be set to identity or NULL to skip this step. By default, the graph is connected: nodes not belonging to the largest connected component are randomly wired to a node in it.

seed

numeric, seed for random number generator

Value

An igraph object

Examples

1
2
3
4
5
g <- generate_graph(
    fun_gen = igraph::barabasi.game,
    param_gen = list(n = 100, m = 3, directed = FALSE),
    seed = 1)
g

b2slab/diffusion documentation built on March 6, 2021, 2:38 a.m.