generate_graph {diffuStats} | R Documentation

## Generate a random graph

### Description

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

### Usage

    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

    g <- generate_graph(
        fun_gen = igraph::barabasi.game,
        param_gen = list(n = 100, m = 3, directed = FALSE),
        seed = 1)
    g
    ## Not run:
    plot(g)

    ## End(Not run)

[Package diffuStats version 0.104.0 Index]