Learn R Programming

causalDisco (version 1.0.1)

sim_dag: Simulate a Random DAG

Description

Simulates a random directed acyclic graph adjacency (DAG) matrix with n nodes and either m edges, edge creation probability p, or edge creation probability range p_range.

Usage

sim_dag(n, m = NULL, p = NULL)

Value

The sampled caugi object.

Arguments

n

The number of nodes.

m

Integer in 0, n*(n-1)/2. Number of edges in the graph. Exactly one of m or p must be supplied.

p

Numeric in [0,1]. Probability of edge creation. Exactly one of m or p must be supplied.

See Also

caugi::generate_graph()

Examples

Run this code
# Simulate a DAG with 5 nodes and 3 edges
sim_dag(n = 5, m = 3)

# Simulate a DAG with 5 nodes and edge creation probability of 0.2
sim_dag(n = 5, p = 0.2)

Run the code above in your browser using DataLab