Skip to contents

Checks if the given caugi graph is a Partially Directed Acyclic Graph (PDAG).

Usage

is_pdag(cg, force_check = FALSE)

Arguments

cg

A caugi_graph object.

force_check

Logical; if TRUE, the function will test if the graph is a PDAG, if FALSE (default), it will look at the graph class and match it, if possible.

Value

A logical value indicating whether the graph is a PDAG.

Examples

cg_dag_class <- caugi_graph(
  A %-->% B,
  class = "DAG"
)
is_pdag(cg_dag_class) # TRUE
#> [1] TRUE
cg_dag_but_pdag_class <- caugi_graph(
  A %-->% B,
  class = "PDAG"
)
is_pdag(cg_dag_but_pdag_class) # TRUE
#> [1] TRUE
cg_cyclic <- caugi_graph(
  A %-->% B,
  B %-->% C,
  C %-->% A,
  D %---% A,
  class = "UNKNOWN",
  simple = FALSE
)
is_pdag(cg_cyclic) # FALSE
#> [1] FALSE

cg_undirected <- caugi_graph(
  A %---% B,
  class = "UNKNOWN"
)
is_pdag(cg_undirected) # TRUE
#> [1] TRUE

cg_pag <- caugi_graph(
  A %o->% B,
  class = "UNKNOWN"
)
is_pdag(cg_pag) # FALSE
#> [1] FALSE