AddLink {RNetica} | R Documentation |
Add link adds an edge from Parent
to Child
. Delete Link
removes that edge. This states that the distribution of child
will be specified conditional on the value of parent
.
Consequently, adding or removing edges with affect the
conditional probability tables associated with the Child
node
(see NodeProbs()
.)
AddLink(parent, child) DeleteLink(parent, child)
parent |
A |
child |
A |
After adding a link parent --> child
, it may be the case that
parent
is in NodeParents(child)
and child
is a member of NodeChildren(parent)
. If child
already has other parents, then the new parent will be added to the
end of the list. The order of the parents can be set by setting
NodeParents(child)
.
In general, the Bayesian network must always be an acyclic directed
graph. Therefore, if parent
is a descendant of child
(that is if is.NodeRelated(child)
, "descendant",
child
is TRUE
), then Netica will generate an error.
The function DeleteLink()
removes the relationship, and the
parent
and child
nodes should no longer be in each
other parent and child lists. The parent list of the child node is
shortened (a stub node for later reconnection is not created as when
NodeParents(child)[i] <- list(NULL)
).
The function AddLinK
invisibly returns the index of the new
parent in the parent list.
The function DeleteLink
invisibly returns the child node.
The Netica API specifies the first argument to DeleteLink_bn()
as an index into the parent list. RNetica maps from the node to the
index.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: AddLink_bn(), DeleteLink_bn()
NeticaNode
, NodeParents()
,
NodeChildren()
, is.NodeRelated()
sess <- NeticaSession() startSession(sess) abnet <- CreateNetwork("AABB", session=sess) A <- NewDiscreteNode(abnet, "A") B <- NewDiscreteNode(abnet, "B") AddLink(A,B) stopifnot( is.element(list(A),NodeParents(B)), is.element(list(B),NodeChildren(A)) ) DeleteLink(A,B) stopifnot( !is.element(list(A),NodeParents(B)), !is.element(list(B),NodeChildren(A)) ) DeleteNetwork(abnet) stopSession(sess)