PnetFindNode: Finds nodes in a Netica Pnet.

PnetFindNodeR Documentation

Finds nodes in a Netica Pnet.

Description

The function PnetFindNode finds a node in a Pnet with the given name. If no node with the specified name found, it will return NULL.

The function PnetPnodes returns nodes which have been marked as pnodes, that is nodes that have “pnodes” in their PnodeLabels.

Usage

## S4 method for signature 'NeticaBN'
PnetFindNode(net, name)
## S4 method for signature 'NeticaBN'
PnetPnodes(net)
## S4 replacement method for signature 'NeticaBN'
PnetPnodes(net) <- value

Arguments

net

The Pnet to search.

name

A character vector giving the name or names of the desired nodes. Names must follow the IDname protocol.

value

A list of NeticaNode objects in the network to be marked as Pnodes.

Details

Although each Pnode belongs to a single network, a network contains many nodes. Within a network, a node is uniquely identified by its name. However, nodes can be renamed (see NodeName()).

A NeticaNode is also a Pnode if it has the label (node set) “pnodes”.

The function PnetPnodes() returns all the Pnodes in the network, however, the order of the nodes in the network could be different in different calls to this function.

The form PnetPnodes(net)<-value sets the list of nodes in value to be the set of Pnodes; removing nodes which are not in the value from the set of Pndoes.

The Pnodes are not necesarily all of the nodes in the Netica network. The complete list of ndoes can be found through the RNetica::NetworkAllNodes function.

Value

The Pnode object or list of Pnode objects corresponding to names, or a list of all node objects for PnetPnodes(). In the latter case, the names will be set to the node names.

Note

NeticaNode objects do not survive the life of a Netica session (or by implication an R session). So the safest way to "save" a NeticaNode object is to recreate it using PnetFindNode() after the network is reloaded.

Author(s)

Russell Almond

References

http://norsys.com/onLineAPIManual/index.html, GetNodeNamed_bn(), GetNetNodes_bn()

See Also

Generic functions: PnetPnodes(), PnetFindNode(),

Related functions in RNetica package: NetworkFindNode, NetworkAllNodes

Examples

sess <- NeticaSession()
startSession(sess)

tnet <- CreateNetwork("TestNet",sess)
nodes <- NewDiscreteNode(tnet,c("A","B","C"))

nodeA <- PnetFindNode(tnet,"A")
stopifnot (nodeA==nodes[[1]])

nodeBC <- PnetFindNode(tnet,c("B","C"))
stopifnot(nodeBC[[1]]==nodes[[2]])
stopifnot(nodeBC[[2]]==nodes[[3]])

allnodes <- PnetPnodes(tnet)
stopifnot(length(allnodes)==0)

## Need to mark nodes a Pnodes before they will be seen.
nodes <- lapply(nodes,as.Pnode)
allnodes <- PnetPnodes(tnet)
stopifnot(length(allnodes)==3)
stopifnot(any(sapply(allnodes,"==",nodeA))) ## NodeA in there somewhere.

DeleteNetwork(tnet)

ralmond/PNetica documentation built on Sept. 19, 2023, 8:27 a.m.