require("graph") ## Using package 'graph' => plot() method (via package 'Rgraphviz'):
(bg7 <- bGraph(7)) # 8 nodes {Mom, D1..D7}; 7 edges
plot(bg7) # draws the graph
(bgD3 <- bGraph(3, mode="directed"))
plot(bgD3) # directed: using arrows
(bgw2 <- bGraph(2, weights = c(10,1)))
plot(bgw2) # {maybe use lwd for weights in the future?}
if(require("Matrix"))
show(as(bgw2, "sparseMatrix")) # shows the weights
Run the code above in your browser using DataCamp Workspace