AddLink {RNetica}R Documentation

Adds or removes a link between two nodes in a Netica network.

Description

Add link adds an edge from Parent to Child. Delete Link removes that edge. This states that the distribution of child will be specified conditional on the value of parent. Consequently, adding or removing edges with affect the conditional probability tables associated with the Child node (see NodeProbs().)

Usage

AddLink(parent, child)
DeleteLink(parent, child)

Arguments

parent

A NeticaNode representing an independent variable to be added to the conditioning side of the relationship. The nodes parent and child must both be in the same network.

child

A NeticaNode representing dependent variable to be added to the conditioning side of the relationship.

Details

After adding a link parent --> child, it may be the case that parent is in NodeParents(child) and child is a member of NodeChildren(parent). If child already has other parents, then the new parent will be added to the end of the list. The order of the parents can be set by setting NodeParents(child).

In general, the Bayesian network must always be an acyclic directed graph. Therefore, if parent is a descendant of child (that is if is.NodeRelated(child), "descendant", child is TRUE), then Netica will generate an error.

The function DeleteLink() removes the relationship, and the parent and child nodes should no longer be in each other parent and child lists. The parent list of the child node is shortened (a stub node for later reconnection is not created as when NodeParents(child)[i] <- list(NULL)).

Value

The function AddLinK invisibly returns the index of the new parent in the parent list.

The function DeleteLink invisibly returns the child node.

Note

The Netica API specifies the first argument to DeleteLink_bn() as an index into the parent list. RNetica maps from the node to the index.

Author(s)

Russell Almond

References

http://norsys.com/onLineAPIManual/index.html: AddLink_bn(), DeleteLink_bn()

See Also

NeticaNode, NodeParents(), NodeChildren(), is.NodeRelated()

Examples

sess <- NeticaSession()
startSession(sess)

abnet <- CreateNetwork("AABB", session=sess)
A <- NewDiscreteNode(abnet, "A")
B <- NewDiscreteNode(abnet, "B")

AddLink(A,B)

stopifnot(
  is.element(list(A),NodeParents(B)),
  is.element(list(B),NodeChildren(A))
)

DeleteLink(A,B)

stopifnot(
  !is.element(list(A),NodeParents(B)),
  !is.element(list(B),NodeChildren(A))
)

DeleteNetwork(abnet)
stopSession(sess)

[Package RNetica version 0.8-4 Index]