Skip to main content

Edge specification operators

Source: R/dsl.R

Description

Infix operators that specify edges inside cgraph(), add_edges(), remove_edges(), apply_background_knowledge(), and dag_to_mpdag(), e.g. A %-->% X + Y.

Usage

lhs %-->% rhs

lhs %<--% rhs

lhs %---% rhs

lhs %<->% rhs

lhs %o->% rhs

lhs %<-o% rhs

lhs %o--% rhs

lhs %--o% rhs

lhs %o-o% rhs

lhs %!-->% rhs

lhs %!<--% rhs

Arguments

lhs, rhs Node name(s): a bare symbol, a string, or a +-combination or c() of either.

Details

Use + for several nodes on one side: A %-->% X + Y means A --> X and A --> Y. Chaining connects consecutive nodes: X %-->% M %-->% Y means X --> M and M --> Y.

Operator Meaning
%-->% directed, src --> dst
%<--% directed, dst --> src
%---% undirected
%<->% bidirected
%o->% partially directed, src o-> dst
%<-o% partially directed, dst o-> src
%o--% partially undirected, src o-- dst
%--o% partially undirected, dst o-- src
%o-o% partial (both ends circle)

apply_background_knowledge() and dag_to_mpdag() also take %!-->% (src --> dst is forbidden) and %!<--% (dst --> src is forbidden), where %-->% and %<--% mean a required edge.

These functions read the operators from their ... without evaluating them. The operators are not exported, so they can’t be used anywhere else.

Value

None, since the operators are never called.

Examples

dag <- cgraph(A %-->% X + Y, X %-->% M %-->% Y)
edges(dag)
#>   from to type
#> 1    A  X  -->
#> 2    A  Y  -->
#> 3    X  M  -->
#> 4    M  Y  -->