NeticaNode {RNetica}R Documentation

An object referencing a node in a Netica Bayesian network.

Description

OBSOLETE: See NeticaNode (class) for current (RNetica 0.5 and beyond) implementation.

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.

Usage

is.NeticaNode(x)

Arguments

x

The object to print or test

Details

This information is current only for Version 0.4 and earlier of RNetica.

This is an object of class NeticaNode. It consists of a name, and an invisible handle to a Netica node. 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().

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

For active nodes, the equality test tests to see if both object point to the same object in Netica memory. Note that the name of the node is embedded in the R object implementation and may get out of sync with Netica memory, so the printed representations may be unequal even if it points to the same node. For inactive nodes, the objects are compared using the cached names.

Value

For toString() a string. The function print() is usually called for its side effects.

The function is.NeticaNode() returns a logical scalar depending on whether or not its argument is a NeticaBN.

Note

The first two paragraphs are obsolete as of Version 0.5.

Internally, the NeticaNode objects are character strings with extra attributes. So as.character(node) will return the name of the node. Because of this, the default c() function will strip off the essential attributes returning them to strings. Use the cc() function instead to avoid this problem.

Note that if a NeticaNode object is stored in an R object, and the Node is subsequently renamed (with a call to the set method of NodeName), the old object may persist with the wrong name. This may result in a situation where the printed names of the objects are different but node1==node2 returns true. This can be fixed with the code NodeName(net) <- NodeName(net).

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

Note that RNetica is lazy about creating NeticaNode objects for nodes when a network is read from a file. Probably users should avoid creating or saving NetworkNode objects unless they are going to use them frequently.

Author(s)

Russell Almond

References

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

See Also

NeticaBN, NetworkFindNode(), is.active(), is.discrete(), NewContinuousNode(), NewDiscreteNode(), DeleteNodes(), NodeName(), NodeStates(), NodeLevels(), cc()

Examples

## Not run: 
nety <- CreateNetwork("yNode")

node1 <- NewContinuousNode(nety,"aNode")
stopifnot(is.NeticaNode(node1))
stopifnot(is.active(node1))
stopifnot(as.character(node1)=="aNode")

node2 <- NetworkFindNode(nety,"aNode")
stopifnot(as.character(node2)=="aNode")
stopifnot(node1==node2)

NodeName(node1) <- "Unused"
stopifnot(node1==node2)
## Warning:  The following expression is true!
as.character(node1) != as.character(node2)

noded <- DeleteNodes(node1)
stopifnot(!is.active(node1))
stopifnot(!is.active(node2))
stopifnot(as.character(noded)=="Unused")
stopifnot(noded == node1)
## Warning:  The following expression is true!
node1 != node2

DeleteNetwork(nety)


## End(Not run)

[Package RNetica version 0.5-4 Index]