graph generation tools {bnlearn} | R Documentation |
Generate an empty or random graph from a given set of nodes.
empty.graph(nodes) random.graph(nodes, prob = 0.5)
nodes |
a vector of character strings, the labels of the nodes. |
prob |
a numeric value, the probability of connecting a node to another node with higher ordering. |
Both empty.graph
and random.graph
return an
object of class bn
.
The random.graph
function uses the same algorithm as the
randomDAG
function in package pcalg and generates
graphs whose node ordering is given by the order of the labels
in the nodes
parameter.
Marco Scutari
empty.graph(LETTERS[1:8]) # # Bayesian network learned via Conditional Independence methods # # model: # [H][G][F][E][D][C][B][A] # nodes: 8 # arcs: 0 # undirected arcs: 0 # directed arcs: 0 # average markov blanket size: 0.00 # average neighbourhood size: 0.00 # average branching factor: 0.00 # # learning algorithm: random/generated # tests used in the learning procedure: 0 # random.graph(LETTERS[1:8]) # <insert the description of a random graph here> plot(random.graph(LETTERS[1:8])) plot(random.graph(LETTERS[1:8], prob = 0.2))