AbsorbNodes {RNetica} | R Documentation |
This function deletes NeticaNode
connecting
the parents of the deleted node to its children. If multiple nodes
are passed as the argument, then all of the nodes are absorbed. The
joint probability distribution over the remaining nodes should be the
same as the marginal probability distribution over the remaining nodes
before the nodes were deleted.
AbsorbNodes(nodes)
nodes |
A |
This function provides a way of removing a node without affecting the
connectivity, or the joint probability of the remaining nodes. In
particular, all of the relationship tested by
is.NodeRelated()
among the remaining nodes should remain
true (or false) when we are done.
Returns NULL
.
There is a bug in version 5.04 (and 5.10) of the Netica API where
AbsorbNodes can crash if some nodes have visual information and some
do not. For the moment, it is recommended that you call
ReadNetworks
with loadVisual=FALSE
to work around
this problem.
Russell Almond
http://norsys.com/onLineAPIManual/index.html: AbsorbNodes_bn()
NeticaNode
, AddLink()
,
NodeChildren()
, NodeParents()
,
ReverseLink()
, is.NodeRelated()
sess <- NeticaSession() startSession(sess) anet <- CreateNetwork("Absorbent",sess) xnodes <- NewDiscreteNode(anet,paste("X",1:5,sep="_")) AddLink(xnodes[[1]],xnodes[[2]]) AddLink(xnodes[[2]],xnodes[[3]]) AddLink(xnodes[[3]],xnodes[[4]]) AddLink(xnodes[[3]],xnodes[[5]]) stopifnot( all(match(xnodes[4:5],NodeChildren(xnodes[[3]]),nomatch=0)>0), is.NodeRelated(xnodes[[2]],xnodes[[3]],"parent"), is.NodeRelated(xnodes[[2]],xnodes[[1]],"child") ) ## These are leaf nodes, shouldn't change topology, except locally. AbsorbNodes(xnodes[4:5]) stopifnot( ## Nodes 4 and 5 are now deleted all(!is.active(xnodes[4:5])), all(anet$listNodes() == c("X_1","X_2","X_3")), length(NodeChildren(xnodes[[3]]))==0, is.NodeRelated(xnodes[[2]],xnodes[[3]],"parent"), is.NodeRelated(xnodes[[2]],xnodes[[1]],"child") ) ## This should connect X1->X3 AbsorbNodes(xnodes[[2]]) stopifnot( ## Node 2 is now deleted !is.active(xnodes[[2]]), length(NodeChildren(xnodes[[3]]))==0, is.NodeRelated(xnodes[[1]],xnodes[[3]],"parent"), is.NodeRelated(xnodes[[3]],xnodes[[1]],"child") ) DeleteNetwork(anet) stopSession(sess)