The bnlearn package has a random graph generator in the 'random.graph' function. These random graphs are used as starting graphs in structure inference. However, if there is a set of white listed edges, some of those edges may clash with random edges in the random graph. For example, the whitelisted edges and random edges might introduce cycles. This function is a wrapper for bn.learn's random.graph function that allows for a whitelist. It uses the same arguments as random.graph, except for the whitelist argument, which is the same as the whitelist argument used in bnlearn's structure inference methods. Ideally, the random.graph function would take a whitelist argument and add random edges on a starter graph that included those whitelisted edges. This presents a less elegant work-around, where random edges are added to nodes that are not in the whitelist. If all the nodes are in the whitelist, then simply a graph based on the whitelist is return.
1 | random_graph(nodes, whitelist = NULL, num = 1, ..., debug = FALSE)
|
nodes |
a vector of character strings, the labels of the nodes. |
num |
an integer, the number of graphs to be generated. |
... |
additional arguments passed to either the preferential attachment algorithm (if there is a whitelist) or the random.graph algorithm. |
a |
matrix with two columns (optionally labeled "from" and "to"), containing a set of arcs to be included in the graph. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.