buildParentList: Builds a list of parents of nodes in a graph

buildParentListR Documentation

Builds a list of parents of nodes in a graph

Description

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).

Usage

buildParentList(sm, start = colnames(sm)[1], ord = mcSearch(sm, start))

Arguments

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 sm giving the ordering of nodes.

Details

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.

Value

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.

Author(s)

Russell Almond

References

Almond, R. G. (2010). ‘I can name that Bayesian network in two matrixes.’ International Journal of Approximate Reasoning. 51, 167-178.

See Also

mcSearch, structMatrix

Examples

data(MathGrades)
MG.struct <- structMatrix(MathGrades$var)

parents <- buildParentList(MG.struct)   # Arbitrary start
parentsa <- buildParentList(MG.struct, "Algebra") # Put algebra first.



ralmond/CPTtools documentation built on Dec. 27, 2024, 7:15 a.m.