Learn R Programming

caugi (version 1.0.0)

is_acyclic: Is the caugi acyclic?

Description

Checks if the given caugi graph is acyclic.

Usage

is_acyclic(cg, force_check = FALSE)

Value

A logical value indicating whether the graph is acyclic.

Arguments

cg

A caugi object.

force_check

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

Details

Logically, it should not be possible to have a graph class of "DAG" or "PDAG" that has cycles, but in case the user modified the graph after creation in some unforeseen way that could have introduced cycles, this function allows to force a check of acyclicity, if needed.

See Also

Other queries: ancestors(), anteriors(), children(), descendants(), districts(), edge_types(), edges(), exogenous(), is_admg(), is_ag(), is_caugi(), is_cpdag(), is_dag(), is_empty_caugi(), is_mag(), is_pdag(), is_ug(), m_separated(), markov_blanket(), neighbors(), nodes(), parents(), same_nodes(), spouses(), subgraph(), topological_sort()

Examples

Run this code
cg_acyclic <- caugi(
  A %-->% B,
  B %-->% C,
  class = "DAG"
)
is_acyclic(cg_acyclic) # TRUE
cg_cyclic <- caugi(
  A %-->% B,
  B %-->% C,
  C %-->% A,
  class = "UNKNOWN"
)
is_acyclic(cg_cyclic) # FALSE

Run the code above in your browser using DataLab