R/simulation.R

Defines functions rbn.backend topological.ordering

# do a partial ordering of the nodes of a graph.
topological.ordering = function(x, start = NULL, reverse = FALSE,
    debug = FALSE) {

  if (is.null(start))
    roots = root.leaf.nodes(x, leaf = reverse)
  else
    roots = start

  to.do = .Call(call_topological_ordering,
                bn = x,
                root.nodes = roots,
                reverse = reverse,
                debug = debug)

  if (is.null(start))
    return(names(sort(to.do)))
  else
    return(names(sort(to.do[to.do > 0])))

}#SCHEDULE

# use the Logic Sampling (LS) algorithm as described in "Bayesian Artificial
# Intelligence", Korb & Nicholson, chap 3.6.1.
rbn.backend = function(x, n, fix = TRUE, debug = FALSE) {

  .Call(call_rbn_master,
        fitted = x,
        n = as.integer(n),
        fix = fix,
        add.metadata = FALSE,
        debug = debug)

}#RBN.BACKEND

Try the bnlearn package in your browser

Any scripts or data that you put into this service are public.

bnlearn documentation built on Sept. 11, 2024, 8:27 p.m.