| Index | Topics |
| arc operations {bnlearn} | R Documentation |
Drop, add or set the direction of an arc
Description
Drop, add or set the direction of an arc.
Usage
set.arc(x, from, to, check.cycles = TRUE, debug = FALSE) drop.arc(x, from, to, debug = FALSE) reverse.arc(x, from, to, check.cycles = TRUE, debug = FALSE)
Arguments
x |
an object of class bn. |
from |
a character string, the label of a node. |
to |
a character string, the label of another node. |
check.cycles |
a boolean value. If TRUE the graph is tested for acyclicity; otherwise the graph is
returned anyway. |
debug |
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is
completely silent. |
Details
The set.arc function operates in the following way:
- if there is no arc between
fromandto, the arcfrom->tois added. - if there is an undirected arc between
fromandto, its direction is set tofrom-to. - if the arc
to->fromis present, it's reversed. - if the arc
from->tois present, no action is taken.
The drop.arc function operates in the following way:
- if there is no arc between
fromandto, no action is taken. - if there is an undirected arc between
fromandto, it's dropped. - if there is a directed arc between
fromandto, it's dropped regardless of its direction.
The reverse.arc function operates in the following way:
- if there is no arc between
fromandto, it returns an error. - if there is an undirected arc between
fromandto, it returns an error. - if the arc
to->fromis present, it's reversed. - if the arc
from->tois present, it's reversed.
Value
set.arc and drop.arc return invisibly an updated copy of x.
Author(s)
Marco Scutari
Examples
data(learning.test) res = gs(learning.test) ## use debug = TRUE for more information ## Not run: set.arc(res, "A", "B", debug = TRUE) drop.arc(res, "A", "B", debug = TRUE) reverse.arc(res, "A", "D", debug = TRUE) ## End(Not run)
| Index | Topics |
