Learn R Programming

caugi (version 1.0.0)

subgraph: Get the induced subgraph

Description

Get the induced subgraph

Usage

subgraph(cg, nodes = NULL, index = NULL)

Value

A new caugi that is a subgraph of the selected nodes.

Arguments

cg

A caugi object.

nodes

A vector of node names, a vector of unquoted node names, or an expression combining these with + and c().

index

A vector of node indexes.

See Also

Other queries: ancestors(), anteriors(), children(), descendants(), districts(), edge_types(), edges(), exogenous(), is_acyclic(), 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(), topological_sort()

Examples

Run this code
cg <- caugi(
  A %-->% B,
  B %-->% C,
  class = "DAG"
)
sub_cg <- subgraph(cg, c("B", "C"))
cg2 <- caugi(B %-->% C, class = "DAG")
all(nodes(sub_cg) == nodes(cg2)) # TRUE
all(edges(sub_cg) == edges(cg2)) # TRUE

Run the code above in your browser using DataLab