rand_init_dags: Randomly generates DAGs of specified sparsity.

Description Usage Arguments Details Value Examples

View source: R/zero_est_graph.R

Description

Randomly generates DAGs of specified sparsity.

Usage

1
rand_init_dags(m, init_spars, init_eachs)

Arguments

m

An integer, the number of nodes.

init_spars

A vector of numbers between 0 and 1, inclusive. It is assumed that as.integer(m*(m-1)/2*(1-init_spars)) does not contain duplicates.

init_eachs

A positive integer or a vector of positive integers of the same length as init_spars.

Details

Randomly generates DAGs of specified sparsity. For each spar in init_spars, the function generates a complete graph, then randomly remove as.integer(m*(m-1)/2*(1-spar)) edges. Finally, the ordering of the m nodes are randomized. For each spar = init_spars[i] this is repeated init_eachs (if integer) or init_eachs[i] (if init_eachs is a vector of integers) times; duplicate graphs are avoided and at most 200 attempts will be made when generating each new graph. Note that for spar = 0 there will only be one empty graph returned.

Value

A list of adjacency matrices each of shape m by m.

Examples

1
2
rand_init_dags(4, c(0, 0.25, 0.5, 0.75, 1), 5)
rand_init_dags(10, c(0, 0.25, 0.5, 0.75, 1), 5)

sqyu/ZiDAG documentation built on Jan. 19, 2021, 4:11 p.m.