Skip to main content

Node-set queries

Source: R/queries.R, R/jlbind-wrappers.R

Description

parents() and children() are the nodes directly connected to node by a directed edge. ancestors() and descendants() are all nodes from which (respectively, to which) node is reachable by following directed edges. spouses() are the nodes connected to node by a bidirected edge (node <-> spouse).

Usage

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

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

parents(cg, node)

children(cg, node)

spouses(cg, node)

Arguments

cg

A graph created with cgraph(). Supported classes vary by function:

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.

Details

See neighbors(), markov_blanket(), and possible-queries for the remaining node-set queries, which take extra arguments.

Value

Sorted character vector of node names.

Examples

dag <- cgraph(A %-->% X + Y, X %-->% M %-->% Y)
parents(dag, "M")
#> [1] "X"
children(dag, "X")
#> [1] "M"
ancestors(dag, "Y")
#> [1] "A" "M" "X"
descendants(dag, "X")
#> [1] "M" "Y"
descendants(dag, "X", open = FALSE)
#> [1] "M" "X" "Y"