PnetFindNode {PNetica} | R Documentation |
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
PnetAllNodes()
returns a list of all nodes in the network.
PnetFindNode(net, name) PnetAllNodes(net)
net |
The |
name |
A character vector giving the name or names of the desired nodes.
Names must follow the |
Although each PnetNode
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()
).
The function PnetAllNodes()
returns all the nodes in the
network, however, the order of the nodes in the network could be
different in different calls to this function.
The PnetNode
object or list of PnetNode
objects corresponding to names
, or a list of all node objects for
PnetAllNodes()
. In the latter case, the names will be set
to the node names.
PnetNode
objects do not survive the life of a
Netica session (or by implication an R session). So the safest way to
"save" a PnetNode
object is to recreate it using
PnetFindNode()
after the network is reloaded.
Russell Almond
http://norsys.com/onLineAPIManual/index.html, GetNodeNamed_bn(), GetNetNodes_bn()
NodeNet()
retrieves the network from the node.
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. ## Not run: ## Safe way to preserve node and network objects across R sessions. tnet <- WriteNetworks(tnet,"Tnet.neta") q(save="yes") # R library(RNetica) sess <- NeticaSession() startSession(sess) tnet <- ReadNetworks(tnet,sess) nodes <- NetworkFindNodes(tnet,as.character(nodes)) ## End(Not run) DeleteNetwork(tnet)