Skip to contents

Get descendants of nodes in a caugi

Usage

descendants(
  cg,
  nodes = NULL,
  index = NULL,
  open = caugi_options("use_open_graph_definition")
)

Arguments

cg

A caugi object.

nodes

A character vector of node names.

index

A vector of node indexes.

open

Boolean. Determines how the graph is interpreted when retrieving descendants. Default is taken from caugi_options("use_open_graph_definition"), which by default is TRUE.

Value

Either a character vector of node names (if a single node is requested) or a list of character vectors (if multiple nodes are requested).

Examples

cg <- caugi(
  A %-->% B,
  B %-->% C,
  class = "DAG"
)
descendants(cg, "A") # "B" "C"
#> [1] "B" "C"
descendants(cg, "A", open = FALSE) # "A" "B" "C"
#> [1] "A" "B" "C"
descendants(cg, index = 2) # "C"
#> [1] "C"
descendants(cg, "B") # "C"
#> [1] "C"
descendants(cg, c("B", "C"))
#> $B
#> [1] "C"
#> 
#> $C
#> NULL
#> 
#> $B
#> [1] "C"
#>
#> $C
#> NULL