buildParentList | R Documentation |
Takes an incidence matrix describing a graph, and an order of the
nodes, and builds a list of parents for each node. If the ord
argument is not supplied, the ordering is constructed through maximum
cardinality search (see mcSearch
).
buildParentList(sm, start = colnames(sm)[1], ord = mcSearch(sm, start))
sm |
A logical matrix whose rows and columns correspond to nodes (variables) and a true value indicates an edge between the variables. |
start |
The name of the first element. |
ord |
A vector of size equal to the number of columns of
|
The sm
argument should be an incidence matrix for a graph, with
row and column names set to the names of the nodes/variables.
A node i
is a parent of node j
if
They are neighbors, that is sm[i,j] == TRUE
.
The node i
appears before node j
in ord
,
that is ord[i] < ord[j]
.
The argument start
is used only if ord
is not supplied,
in which case it is passed to mcSearch
.
A list with as many elements as there are columns in sm
, and
whose elements appear in the order specified by ord
. Each
element of that list is a character vector giving the names of the
parents.
Russell Almond
Almond, R. G. (2010). ‘I can name that Bayesian network in two matrixes.’ International Journal of Approximate Reasoning. 51, 167-178.
mcSearch
, structMatrix
data(MathGrades)
MG.struct <- structMatrix(MathGrades$var)
parents <- buildParentList(MG.struct) # Arbitrary start
parentsa <- buildParentList(MG.struct, "Algebra") # Put algebra first.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.