ParentStates {RNetica} | R Documentation |
This function returns a list each of whose elements is a character
vector giving the states of the parent variables (i.e., the result of
calling NodeStates)
on each of the elements of
NodeParents(node)
). The names of this list are the
names assigned to the edges through NodeInputNames(node)
,
or the names of the parent variables if edge names were not supplied.
ParentStates(node) ParentNames(node)
node |
An active |
For ParentStates(node)
, named list where each element
corresponds to the states of a parent variable. If node has no
parents, it returns a list of length 0.
The function ParentNames(node)
returns
names(ParentNames(node)
, only is faster.
This is a slightly more sophisticated version of
lapply(NodeParents(node), NodeStates)
. It does minimal
checking so that it can be fast.
Russell Almond
NodeStates()
, NodeParents()
,
NodeInputNames()
sess <- NeticaSession() startSession(sess) abc1 <- CreateNetwork("ABC1", session=sess) A <- NewDiscreteNode(abc1,"A",c("A1","A2","A3","A4")) B <- NewDiscreteNode(abc1,"B",c("B1","B2","B3")) C <- NewDiscreteNode(abc1,"C",c("C1","C2")) stopifnot( length(ParentStates(A)) == 0 ) AddLink(A,B) Bpars <- ParentStates(B) stopifnot( length(Bpars) == 1, names(Bpars) == "A", Bpars$A==NodeStates(A) ) AddLink(A,C) AddLink(B,C) NodeInputNames(C) <- c("A_type","B_type") Cpars <- ParentStates(C) stopifnot( length(Cpars) == 2, names(Cpars) == c("A_type","B_type"), Cpars[[1]]==NodeStates(A), Cpars$B_type==NodeStates(B) ) DeleteNetwork(abc1) stopSession(sess)