set.seed(123)
g <- randomDAG(n = 5, prob = 0.3) ## generate random DAG
if(require(Rgraphviz)) {
plot(g)
}
## edge weights as matrix
wgtMatrix(g)
## for comparison: edge weights in graph object
g@edgeData@data
Run the code above in your browser using DataLab