NodeInputNames {RNetica}R Documentation

Associates names with incoming edges on a Netica node.

Description

The function NodeInputNames() can be used to set or retrieve names for each of the parents of node. This facilitates operations such as copying and reconnecting the nodes.

Usage

NodeInputNames(node)
NodeInputNames(node) <- value

Arguments

node

A NeticaNode object whose parent link names will be retrieved or set.

value

A character vector of length length(NodeParents(node) giving the new names. Names must conform to the IDname convention.

Details

When a parent node is detached from a child, Netica names the link with the name of the old node. For example, suppose that the following commands were executed AddLink(A,C); AddLink(B,C). Then if the node B is detached, via NodeParents(C)[2]<-list(NULL), Netica will replace B with a stub node, and name the link "B". The command NodeParents(C)$B <- D would then attach the node D where the old node was attached.

Rather than relying on the automatic naming scheme, the node names can be directly set using NodeInputNames(node)<-newvals. Netica will not rename a detached link if there already exists a name for that link. Explicitly naming the links rather than relying on Netica's naming scheme is probably good practice. If node input names are set, then they will be used names for the return value of NodeParents()

The getter form NodeInputNames() returns the currently set names of the input links. If an input link whose name has not been set either directly or via inserting a NULL in NodeParents() has a name of "".

Value

The function NodeInputNames() returns a character vector of the same length as GetNodeParents() giving the current names of the links. If a link has not yet been named, the corresponding entry of the vector will be the empty string.

The setter function returns the node object invisibly.

Note

To detach a parent, you must use list(NULL) on the left hand side of NodeParents(node)[i] <- list(NULL) and not NULL.

Author(s)

Russell Almond

References

http://norsys.com/onLineAPIManual/index.html: GetNodeInputNames_bn(), SetNodeInputNames_bn(), SwitchNodeParent_bn()

See Also

NeticaNode, AddLink(), NodeParents()

Examples

sess <- NeticaSession()
startSession(sess)
abnet <- CreateNetwork("AB", session=sess)

anodes <- NewDiscreteNode(abnet, paste("A",1:3,sep=""))
B <- NewDiscreteNode(abnet,"B")

NodeParents(B) <- anodes
stopifnot(
  all(NodeInputNames(B)=="")
)

NodeParents(B)[2] <- list(NULL)
stopifnot(
  NodeInputNames(B)==c("","A2","")
)

## Now can use A2 as name
D <- NewDiscreteNode(abnet,"D")
NodeParents(B)$A2 <- D
## But name doesn't change
stopifnot(
  NodeInputNames(B)==c("","A2","")
)

##Name the inputs
NodeInputNames(B) <- paste("Input",1:3,sep="")
stopifnot(
  names(NodeParents(B))[2]=="Input2"
)

## Now detaching nodes doesn't change input names.
NodeParents(B)[1] <- list(NULL)
stopifnot(
  NodeKind(NodeParents(B)[[1]])=="Stub",
  NodeInputNames(B)[1]=="Input1"
)

DeleteNetwork(abnet)
stopSession(sess)

[Package RNetica version 0.8-4 Index]