graph-randomdag.Rd
Generate a random directed acyclic graph (DAG)
random_dag(V, maxpar = 3, wgt = 0.1)
An igraph object.
If the maximum number of parents for a node is, say 3 and wgt=0.1, then the probability of the node ending up with 0,1,2,3 parents is proportional to 0.1^0, 0.1^1, 0.1^2, 0.1^3.
dg <- random_dag(1:1000, maxpar=5, wgt=.9)
table(sapply(vpar(dg),length))
#>
#> 1 2 3 4 5 6
#> 216 209 158 151 135 131
dg <- random_dag(1:1000, maxpar=5, wgt=.5)
table(sapply(vpar(dg),length))
#>
#> 1 2 3 4 5 6
#> 510 264 126 59 25 16
dg <- random_dag(1:1000, maxpar=5, wgt=.1)
table(sapply(vpar(dg),length))
#>
#> 1 2 3 4
#> 893 96 9 2