NeticaNode-class {RNetica} | R Documentation |
"NeticaNode"
This object is returned by various RNetica functions which create or
find nodes in a NeticaBN
network. A NeticaNode
object represents a node object inside of Netica's memory. The
function is.active()
tests whether the node is still a valid
reference.
This is an object of class NeticaNode
. It consists of a name,
and an pointer to a Netica node in the workspace. The function
is.active()
tests the state of that handle and returns
FALSE
if the node is no longer in active memory (usually
because of a call to DeleteNode()
or DeleteNetwork()
.
NeticaNode
s come in two types: discrete and continuous (see
is.discrete()
). The two types give slightly different
meanings to the NodeStates()
and
NodeLevels()
attributes of the node. The printed
representation shows whether the node is discrete, continuous or
inactive (deleted).
NeticaNode
objects are created at two different times. First,
when the user creates a node in a network using the
NewContinuousNode()
or NewDiscreteNode()
functions. The second is when a user first reads the network in from a
file using ReadNetworks
and then subsequently searches
for the node using NetworkFindNode
. Note that this
latter means that there may be nodes in the Netica network for which
no R object has yet been created. When NeticaNode
objects are
created, they are cached in the NeticaBN
object.
Cached objects can be referenced by the nodes
field of the
NeticaBN
object (which is an R
environment
). Thus, the expressions
net$nodes$nodename
and
net$nodes[[nodename]]
both reference a node with
the Netica name nodename
in the network
net
. Note that both of these expressions will yeild
NULL
if no R object has yet been created for the node. The
function NetworkAllNodes(net)
will as a side
effect create node objects for all of the nodes in net
.
The function match
(and consequently %in%
does not like it when the first argument is a node. To get around
this problem, wrap the node in a list. I've added a method for the
function is.element
which does this
automatically.
All reference classes extend and inherit methods from
"envRefClass"
. Note that because this is a
reference class unlike traditional S3 and S4 classes it can be
destructively modified. Also fields (slots) are accessed using the
‘$’ operator.
signature(x = "NeticaNode")
: Sets conditional
probabliity table for node, see Extract.NeticaNode.
signature(x = "NeticaNode")
: Gets conditional
probabliity table for node, see Extract.NeticaNode.
signature(x = "NeticaNode")
: Gets conditional
probabliity table for node, see Extract.NeticaNode.
signature(e1 = "NeticaNode", e2 = "ANY")
:
Tests two nodes for equality
signature(el = "NeticaNode", set = "list")
:
Checks to see if el is in list of nodes.
signature(x = "NeticaNode")
: Makes printed
representation.
signature(x = "NeticaNode")
: Makes character
representation.
Note these should be regarded as read-only from user code.
Name
:Object of class character
giving the
Netica name of the node. Must follow the IDname
rules. This should not be modified by user code, use
NodeName
instead.
Netica_Node
:Object of class externalptr
giving
the address of the node in Netica's memory space.
Net
:Object of class NeticaBN
, a
back reference to the network in which this node resides.
discrete
:Object of class logical
true if the
node is discrete and false otherwise.
show()
:Prints a description of the node.
isActive()
:Returns true if the object currently points to a Netica node, and false if it does not.
clearErrors(severity)
: Calls clearErrors
on
the Net$Session
object.
reportErrors(maxreport, clear)
: Calls
reportErrors
on the Net$Session
object.
initialize(Name, Net, discrete, ...)
: Initialziation
function. Should not be called directly by user code. Use
NewDiscreteNode
or NewContinuousNode
instead.
deactivate()
:Recursively deactives all nodes contained by this network. Should not be called by user code.
NeticaNode
objects are all rendered inactive when
StopNetica()
is called, therefore they do not persist
across R sessions. Generally speaking, the network should be saved,
using WriteNetworks()
and then reloaded in the new
session using ReadNetworks()
. The node objects should
then be recreated via a call to NetworkFindNode()
or
NetworkAllNodes()
.
Russell Almond
http://norsys.com/onLurl/Manual/index.html: AddNodeToNodeset_bn(), RemoveNodeFromNodeset_bn(), IsNodeInNodeset_bn() GetNodeUserData_bn(), SetNodeUserData_bn() (these are used to maintain the back pointers to the R object).
Its container class can be found in NeticaBN
.
The help file Extract.NeticaNode
explains the principle
methods of referencing the conditional probability table.
NetworkFindNode()
,
is.active()
, is.discrete()
,
NewContinuousNode()
, NewDiscreteNode()
,
DeleteNodes()
, NodeName()
,
NodeStates()
, NodeLevels()
,
sess <- NeticaSession() startSession(sess) nety <- CreateNetwork("yNode",sess) node1 <- NewContinuousNode(nety,"aNode") stopifnot(is.NeticaNode(node1)) stopifnot(is.active(node1)) stopifnot(node1$Name=="aNode") node2 <- NetworkFindNode(nety,"aNode") stopifnot(node2$Name=="aNode") stopifnot(node1==node2) NodeName(node1) <- "Unused" stopifnot(node1==node2) node1$Name == node2$Name noded <- DeleteNodes(node1) stopifnot(!is.active(node1)) stopifnot(!is.active(node2)) stopifnot(noded$Name=="Unused") stopifnot(noded == node1) node1 == node2 DeleteNetwork(nety) stopSession(sess)