Skip to main content

Anterior/posterior node-set queries

Source: R/queries.R

Description

anteriors() finds every node from which node is reachable by following directed edges backward or traversing undirected edges; posteriors() is the mirror notion following directed edges forward. For a DAG, anteriors/posteriors are equivalent to ancestors()/descendants() (no undirected edges exist to traverse); for a PDAG-family or AG-family graph, undirected edges extend the reachable set beyond strict ancestors/descendants.

Usage

anteriors(cg, node, open = getOption("CausalStructures.open", TRUE))

posteriors(cg, node, open = getOption("CausalStructures.open", TRUE))

Arguments

cg A DAG, ADMG, PDAG-family (PDAG, CPDAG, MPDAG), or AG-family (AG, MAG) graph created with cgraph().
node Node name.
open If TRUE (default, from the CausalStructures.open option; see CausalStructures_options), exclude node itself from the result; if FALSE, include it.

Value

Sorted character vector of node names.

Examples

pdag <- cgraph(A %-->% B, B %---% C, class = "PDAG")
anteriors(pdag, "A")
#> character(0)
anteriors(pdag, "C") # reaches B via undirected, A via directed
#> [1] "A" "B"