Index | Topics |
arc operations {bnlearn} | R Documentation |
Drop, add or set the direction of an arc or an edge
Description
Drop, add or set the direction of a directed or undirected arc (also known as edge).
Usage
# arc operations.
set.arc(x, from, to, check.cycles = TRUE, check.illegal = TRUE, debug = FALSE)
drop.arc(x, from, to, debug = FALSE)
reverse.arc(x, from, to, check.cycles = TRUE, check.illegal = TRUE, debug = FALSE)
# edge (i.e. undirected arc) operations
set.edge(x, from, to, check.cycles = TRUE, check.illegal = TRUE, debug = FALSE)
drop.edge(x, from, to, debug = FALSE)
Arguments
x |
an object of class |
from |
a character string, the label of a node. |
to |
a character string, the label of another node. |
check.cycles |
a boolean value. If |
check.illegal |
a boolean value. If |
debug |
a boolean value. If |
Details
The set.arc()
function operates in the following way:
-
if there is no arc between
from
andto
, the arcfrom
\rightarrow
to
is added. -
if there is an undirected arc between
from
andto
, its direction is set tofrom
\rightarrow
to
. -
if the arc
to
\rightarrow
from
is present, it is reversed. -
if the arc
from
\rightarrow
to
is present, no action is taken.
The drop.arc()
function operates in the following way:
-
if there is no arc between
from
andto
, no action is taken. -
if there is a directed or an undirected arc between
from
andto
, it is dropped regardless of its direction.
The reverse.arc()
function operates in the following way:
-
if there is no arc between
from
andto
, it returns an error. -
if there is an undirected arc between
from
andto
, it returns an error. -
if the arc
to
\rightarrow
from
is present, it is reversed. -
if the arc
from
\rightarrow
to
is present, it is reversed.
The set.edge()
function operates in the following way:
-
if there is no arc between
from
andto
, the undirected arcfrom
-to
is added. -
if there is an undirected arc between
from
andto
, no action is taken. -
if either the arc
from
\rightarrow
to
or the arcto
\rightarrow
from
are present, they are replaced with the undirected arcfrom
-to
.
The drop.edge()
function operates in the following way:
-
if there is no undirected arc between
from
andto
, no action is taken. -
if there is an undirected arc between
from
andto
, it is removed. -
if there is a directed arc between
from
andto
, no action is taken.
Value
All functions return invisibly an updated copy of x
.
Author(s)
Marco Scutari
Examples
dag = cpdag(model2network("[A][C][F][B|A][D|A:C][E|B:F]"))
dag
## use debug = TRUE to get more information.
updated = set.arc(dag, "A", "B")
updated
updated = drop.arc(dag, "A", "B")
updated
updated = drop.edge(dag, "A", "B")
updated
updated = reverse.arc(dag, "A", "D")
updated
Index | Topics |